Book Image

HTML5 Game Development by Example: Beginner's Guide

By : Seng Hin Mak
Book Image

HTML5 Game Development by Example: Beginner's Guide

By: Seng Hin Mak

Overview of this book

Table of Contents (18 chapters)
HTML5 Game Development by Example Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
9
Building a Physics Car Game with Box2D and Canvas
Index

Building a chatting application with WebSockets


We now know how many browsers are connected. Suppose we want to build a chat room where users can type a message in their respective browsers and send the message to all the connected users instantly.

Sending a message to the server

We will let the user input a message and then send the message to the node.js server. The server will then forward the message to all the connected browsers. Once a browser receives the message, it displays it in the chat area. In this case, the users are connected to the instant chat room once they load the web page.