Skip to content

Instantly share code, notes, and snippets.

@virbo
Created July 25, 2017 03:49
Show Gist options
  • Save virbo/a3c1dfecb8ea218aeae5523310658751 to your computer and use it in GitHub Desktop.
Save virbo/a3c1dfecb8ea218aeae5523310658751 to your computer and use it in GitHub Desktop.
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
io.on('connection', function(socket){
console.log('new client connected');
socket.on('disconnet', function(){
console.log('a client disconnect');
})
socket.on('notif',function(msg){
console.log('message: '+msg.name+ ': ' + msg.message);
io.emit('notif', {name: msg.name, message: msg.message});
})
});
http.listen(3000, function(){
console.log('listening on *:3000');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment