Skip to content

Instantly share code, notes, and snippets.

@nasitra
Created May 10, 2016 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nasitra/30cde8b259d794c82dc45058d8ead151 to your computer and use it in GitHub Desktop.
Save nasitra/30cde8b259d794c82dc45058d8ead151 to your computer and use it in GitHub Desktop.
Broadcast server implemented with Node.js
var WebSocketServer = require('ws').Server;
var wss = new WebSocketServer({ port: 8080 });
wss.on('connection', function(ws) {
ws.on('message', function(message) {
wss.clients.forEach(function(client) {
client.send(message);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment