Time for action – showing the connection count in a WebSocket application
Carry out the following steps:
- Create a new directory named
client
. - Create an HTML file named
index.html
in theclient
folder. - Now, add a few markups in our HTML file. To do this, put the following code in the
index.html
file:<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>WebSockets demo for HTML5 Games Development: A Beginner's Guide</title> </head> <body> <!-- game elements goes here later --> <script src="js/jquery-2.1.3.min.js"></script> <script src="js/html5games.websocket.js"></script> </body> </html>
- Create a directory named
js
and put the jQuery JavaScript file inside it. - Create a new file named
html5games.websockets.js
as follows:var websocketGame ...
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.