New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
broadcasting to all clients except sender issue #2594
Comments
What's returns from |
@Mad-Head According to docs, returns the same socket instance almost like all other method to keep the chainability. The funny thing is that this traces true console.log(transport === socket.broadcast.to(room)); |
Hi! The flag is used the first time, and then is deleted, hence the result of your second call. |
Hi there! Hm... maybe i wasn't clear enough. Let me make it more obvious: sample1 setTimeout(function(){
// #method1: this works as expected: all clients receive event except the sender
socket.broadcast.to(room).emit(e, data);
},
1000); sample2 var transport = socket.broadcast.to(room);
setTimeout(function(){
// #method2: this doesn't work though: all clients receive this event. Why?! Bug?
transport.emit(e, data);
},
1000); So it's not flag related. The two samples above should work the same, but they don't. That's the problem and i've been beating up against the wall for like 1/2 a day to figure out why. UPD: actually @darrachequesne you are right. I've looked into the source: everytime emit() is called _rooms get flushed and the weird problem occured as while the setTimeout was still in progress another method called emit() and flushed the room (ping was the problem) that's what happened
Thanks a lot for your suggestion @darrachequesne. |
I've noticed this weird behavior while broadcasting to other clients using
socket.broadcast.emit()
Here's the sample code of the problem:
What am i missing here? Why #method2 doesn't work as expected.
Thanks.
The text was updated successfully, but these errors were encountered: