socket.io-stream icon indicating copy to clipboard operation
socket.io-stream copied to clipboard

Broadcast stream?

Open peteruithoven opened this issue 9 years ago • 5 comments

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);
  });
});

peteruithoven avatar Oct 08 '14 12:10 peteruithoven