diff --git a/docs/getting-started.rst b/docs/getting-started.rst index 1927652..8d1fddc 100644 --- a/docs/getting-started.rst +++ b/docs/getting-started.rst @@ -141,6 +141,8 @@ need to change the socket address if you're using a development VM or similar):: socket.onopen = function() { socket.send("hello world"); } + // Call onopen directly if socket is already open + if (socket.readyState == WebSocket.OPEN) socket.onopen(); You should see an alert come back immediately saying "hello world" - your message has round-tripped through the server and come back to trigger the alert. @@ -235,6 +237,8 @@ code in the developer console as before:: socket.onopen = function() { socket.send("hello world"); } + // Call onopen directly if socket is already open + if (socket.readyState == WebSocket.OPEN) socket.onopen(); You should see an alert come back immediately saying "hello world" - but this time, you can open another tab and do the same there, and both tabs will