socket.io-stream
socket.io-stream copied to clipboard
Broadcast stream?
Is there anyway to broadcast the stream to all clients in a namespace or room? I'd like to do something like this:
var nsp = io.of('/user');
nsp.on('connection', function(socket) {
// receive a image by a broadcasting client
ss(socket).on('image', function(incomingStream, data) {
debug("on image ",data);
// send the image
var outgoingStream = ss.createStream();
// emit stream to only one socket
//ss(consumerSocket).emit('image', outgoingStream, {name: data.name});
// broadcast stream to all other clients in namespace
ss(socket).broadcast('image', outgoingStream, {name: data.name});
incomingStream.pipe(outgoingStream);
});
});