Summary

We learned a lot in this chapter about connecting browsers to WebSockets. The messages and events from one browser are sent to all connected browsers in almost real time.

Specifically, we learned how WebSockets provide real-time events by drawing on an existing multiplayer sketchpad. It shows drawings from other users who are connected. We chose Node.js as the server-side WebSocket server. By using this server, we can easily build an event-based server to handle WebSocket requests from browsers. We discussed the relationship between the server and a client, which compares WebSockets with other approaches such as long-polling. We built an instant chat room application. We learned how to implement a server script to send all incoming messages ...

Get HTML5 Game Development by Example : Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.