Skip to content

Instantly share code, notes, and snippets.

@rgruesbeck
Created January 29, 2015 22:35
Show Gist options
  • Save rgruesbeck/b2b30e0d0be0f6a3ae82 to your computer and use it in GitHub Desktop.
Save rgruesbeck/b2b30e0d0be0f6a3ae82 to your computer and use it in GitHub Desktop.
function multiStream(){
var mdm = MuxDemux();
mdm.once('connection', connectNew);
mdm.on('connection', connectHandler);
mdm.on('error', function(err){
console.log(err.toString());
mdm.destroy();
});
mdm.send = function(msg){
this.createWriteStream('msg').write(msg);
};
mdm.broadcast = function(msg){
for (var key in socks) {
if (this.peerId != key) {
socks[key].createWriteStream('msg').write(msg);
}
}
console.log('BROADCAST: ' + msg);
};
return mdm;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment