Created
July 25, 2017 03:49
-
-
Save virbo/a3c1dfecb8ea218aeae5523310658751 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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