Skip to content

Instantly share code, notes, and snippets.

@ruby0x1
Created March 27, 2012 14:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruby0x1/2216589 to your computer and use it in GitHub Desktop.
Save ruby0x1/2216589 to your computer and use it in GitHub Desktop.
Multi-player games in HTML5 : Socket.io on the server side with session
io.sockets.on('connection', function (socket) {
//create a new player, which registers its events
var connection = new Session( socket );
//add to the list of connections (for finding a game)
server.addConnection( connection );
//This will send a message to all clients saying that they connected,
//And hand them their serverid for future interactions.
socket.emit('onConnect', { serverid : connection.serverid });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment