Skip to content

Instantly share code, notes, and snippets.



Last active Oct 27, 2020
What would you like to do? simple cheat sheet
io.on('connection', function(socket){
/* 'connection' is a special event fired on the server when any new connection is made */
socket.on('disconnect', function(){
/* When this individual socket has disconnected, this special event fires */
/* This will send the event 'foobar' with the data to
every connected to socket */
/* This will send the event 'foobar' with the data object to
every connected socket EXCEPT for the socket this is called on */
socket.on('foobar', function(data){
/* Fires whenever this socket receives an event 'foobar'.
You can access the data received inside this callback*/
/* This will send the event 'foobar' with the data to the server */
socket.emit('foobar',data) // A unique string identifying this socket connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.