Time for action – showing the connection count in a WebSocket application

Carry out the following steps:

  1. Create a new directory named client.
  2. Create an HTML file named index.html in the client folder.
  3. 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>
  4. Create a directory named js and put the jQuery JavaScript file inside it.
  5. 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.