Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

9. Hacking HTML5 Connectivity > Hack 70. Use Kaazing’s Remote WebSocket Server ...

Hack 70. Use Kaazing’s Remote WebSocket Server to Echo Simple Messages from a Browser

The echo server is a web-based socket server created by Kaazing and hosted at websocket.org. It demonstrates the capabilities of the WebSocket Protocol by echoing messages sent from the browser.

This example is an extension of the code provided as a test of the Echo Test server on Websocket.org. The code was refactored to follow a more object-oriented approach. You can see the original example at websocket.org.

Let’s open an HTML file and begin by creating a basic WebSocketDemo class in JavaScript. Since JavaScript isn’t class-based, we will follow a very common pseudoclass pattern to manage our code. I provided the basic structure within our JavaScript tags in the following code:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint