Created
July 11, 2017 20:39
-
-
Save kkm/7cb68af4787be8b26fb3a1efc57072c3 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 port = 9001; | |
var io = require('d:/kkm/Desktop/node_modules/socket.io').listen(port); | |
console.log((new Date()) + " Server is listening on port " + port); | |
io.sockets.on('connection', function(socket) { | |
socket.on('message', function(message) { | |
console.log(message); | |
socket.broadcast.emit('message', message); | |
}); | |
socket.on('disconnect', function() { | |
socket.broadcast.emit('user disconnected'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment