Carry out the following steps:
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 = { } // init script when the DOM is ready. $(function(){ // check if existence of WebSockets in browser if (window["WebSocket"]) { /...