-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
socketIo wrongly emits event to all clients #2996
Milestone
Comments
What about that issue, @admirkadriu you found solution? |
You can't reuse the io.to(device.socketId).emit('transferRequested', {
userId: self.identity.userId,
profilePicture: self.identity.userInfo.profilePicture,
callModel: callModel
});
// all flags and rooms are cleaned up after each emit
io.to(device.socketId).emit('transferRequested1', {
userId: self.identity.userId,
profilePicture: self.identity.userInfo.profilePicture,
callModel: callModel
}); |
@darrachequesne that`s OK. The bug happens when an event is called fast multiple times from a client and when server emits from an async function and await is used inside data to be sent. You can emit an event to all clients using the code below. (example)
|
@Merraclius yes, by moving await outside the model.
|
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You want to:
Current behaviour
The code below sends events to all clients. The first event works as expected; the second one sends event to all clients:
The thing is we use node async/await to simplify our code. So, the same thing happens if we change the code like this:
Somehow the second call to await function returns to the scope of the first await call. And the same case as in the first example happens.
Other information
OS: Windows
node -v 7.10.0
socketIo -v 2.0.3
The text was updated successfully, but these errors were encountered: