O'Reilly logo

HTML5: Your visual blueprint™ for designing rich web pages and applications by Adam McDaniel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

SEND WEBSOCKET MESSAGES

After you have created a WebSocket client framework, you can begin to tie outgoing messages as soon as the onOpen() function has started. This function will be run by the open event, after the connection handshake process is complete, indicating that a connection is active.

Because WebSockets are a full-duplex protocol, you can technically send a WebSocket message at any time to the server, after, that is, you have established a successful connection, of course. There is not much point in limiting your outgoing messages to only the onOpen() function, unless the WebSocket service does not require any additional messages.

Therefore, you need a way to be able to send commands, but only while online. This is accomplished by ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required