Skip to content

Instantly share code, notes, and snippets.

@stannehill
Last active December 20, 2015 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stannehill/6105338 to your computer and use it in GitHub Desktop.
Save stannehill/6105338 to your computer and use it in GitHub Desktop.
The third portion of the frontend code for the socket.io blog tutorial.
var playernum = 0;
io.sockets.on('connection', function (socket) {
console.log('connected successfully...');
playernum === 1 ? playernum = 0 : playernum++;
socket.emit('player', {'player': playernum});
socket.on('volley', function (input) {
socket.broadcast.emit('return', {'data': 1});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment