I'm serving my page through localhost (XAMPP, Apache), and on my friend's physical server I run a node.js server that is used for communication with the page (a game).
This is the node.js server code:
var io = require('socket.io').listen(1235);
io.sockets.on('connection', function (socket)
{
socket.on("start", function (data)
{
console.log(data);
});
});
It runs without any errors, but I don't know how to include the socket.io code into my webpage! How do I do that?
2 Options. Per the documentation, you can do a JavaScript src pointing at your node server:
Or you can include it manually, grabbing it from the Git repo at https://github.com/LearnBoost/socket.io-client/blob/master/dist/socket.io.js
Include a script tag in your page:
And it will be served by your node.js server.
Apart from that, you can just follow the examples on socket.io, e.g.: