Closed StratusFearMe21 closed 3 years ago
Okay yes, I do broadcast the message to all the users when a new user joins in, that could be the reason for this. but what I don't understand is it works perfectly fine on my localhost which is so confusing
In the end, the user is redirected to the login page because I have like 4 person limit per room
Hello! It's that guy you were talking to from DogeHouse. I didn't have time to tell you this but based on my knowledge of the Web socket protocol. I think the reason that this is happening is because when someone new joins a room, the server has to send the current state of the room to the new user, So it sends the whole thing across the websocket, but instead of sending the code to just that user, it broadcasts the packet to everyone in the room, duplicating the current code to all user in the room. I can't seem to duplicate this though so this might be a little difficult
I get the problem, when a new user joins, I am emitting the event to everyone in the room, I just need to send this to the user who joined
socket.on("send-message", (body: MessageProps) => {
const roomID = body.userInfo.roomID;
body.socketID = socket.id;
socket.broadcast.to(roomID).emit("message", body);
});
hello, that's how i reproduced the bug
Thanks @firasjaber , another reason I feel this could be happening is when I checked the network tab in the chrome dev tool all I don't see socket connection but xhr polling for some reason, but that is not the case in localhost, it could be a Heroku specific problem in which sockets connection is not being established, I'll try somethings and try to fix this asap
Hello! It's that guy you were talking to from DogeHouse. I didn't have time to tell you this but based on my knowledge of the Web socket protocol. I think the reason that this is happening is because when someone new joins a room, the server has to send the current state of the room to the new user, So it sends the whole thing across the websocket, but instead of sending the code to just that user, it broadcasts the packet to everyone in the room, duplicating the current code to all user in the room. I can't seem to duplicate this though so this might be a little difficult