HTML and CSS Reference
In-Depth Information
Figure 4.8. The simple WebSocket client running in the browser
The next listing shows JavaScript that opens a WebSocket, then listens for messages from
the server. You should create a page named websocket-sample.html and include this listing
in a <script> block. The page doesn't need to do anything or have any content; you'll
determine success by examining the JavaScript console (see step C in the listing).
Listing 4.11. A simple JavaScript WebSockets client
On the server, the WebSocket-Node library is used to extend the base HTTP server. Ap-
pendix E provides the steps you need to take to install this module in Node; if you're fol-
lowing along step-by-step, please take that detour now.
 
 
Search WWH ::




Custom Search