From 58cc3c845df07cc8c5755fad7488800e096a2937 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Mon, 12 Sep 2016 11:58:09 +0100 Subject: [PATCH] Onopen timing fixes in docs --- docs/getting-started.rst | 4 ++++ 1 file changed, 4 insertions(+) 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