What\'s the difference between io.sockets.emit and socket.broadcast.emit? Is it only that broadcast emits to everyone BUT the socket that sends it?
It seems like the
Scenario:1:- By the use of io.sockets.emit Detailed Diagram:-io.sockets.emit
Here Every Socket gets the Message including Initiator.
// BY IO>SOCKETS>EMIT
io.sockets.emit('MyChannelBroadcast',
{
owner:"Anshu Ashish",
clientCount:clients,
message:"Welcome All"
}
);
Scenario:2:- By the use of socket.broadcast.emit Detailed Diagram:-socket.broadcast.emit
Here Every Sockets are getting Message Except One i.e Initiator.
// BY SOCKET>BROADCAST>EMIT
socket.broadcast.emit('BroadCastExceptMe',{data:"HAVE A NICE DAY"});
Conclusion:- Now it will totally depends our business requirement that which one will be preferable.