I have build a game using canvas and Javascript, and I would like to implement multiplayer functionality using WebSockets and Node.js
I'm completely new to Node, and I have managed to get a basic web server up and running with the following code:
var http = require("http");
console.log("Server started at port 8888");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(8888);
It all works, I get the response of "Hello World" when I navigate to to my server IP on port 8888. My question is, is this all I need to start using WebSockets with Node? I have heard people say I still need socket.io so that Node can use sockets, but I don't know if that's just a library to help me use sockets or if Node actually can't understand sockets.
The server basically has to keep a note of all players connected, their scores, their positions on the canvas, etc. A client will poll the server (using WebSockets) occasionally in order to get everyones positions and then update their canvas with the returned information. Would I need socket.io for this? Either way, how would I go about doing this?
Thanks.