Onopen timing fixes in docs

This commit is contained in:
Andrew Godwin 2016-09-12 11:58:09 +01:00
parent 8e84c0ce87
commit 58cc3c845d

View File

@ -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