Last active
August 29, 2015 13:56
-
-
Save ikr7/9107820 to your computer and use it in GitHub Desktop.
ちゃっと
This file contains 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 WebSocket = require('ws'); | |
var wss = new WebSocket.Server({'port': 8080}); | |
wss.broadcast = function(data) { | |
this.clients.forEach(function(client){ | |
client.send(data); | |
}); | |
}; | |
wss.on('connection', function(connection){ | |
connection.on('message', function(message){ | |
wss.broadcast(message); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment