Message Bug
Closed this issue · 1 comments
Issue
I'm having a issue I can't seem to figure out. Consider the following scenario. I have 2 clients. Client A and client B. Client A says "foo". Client A and client B see "foo" for 1 second then it disappears. Then Client B says "bar" and Client A and Client B see "bar" on client B but they also see "foo" on client A. The problem is we're seeing messages that we're suppose to be erased. So for e.g. if there were 20 clients connected and every client said at least one message and 1 second of time passed and all the messages disappeared, then one client decided to say something, every client would not just see their message but all the previous messages on all the other clients as well.
server.js https://github.com/valkyrienyanko/io-game-v2/blob/master/server.js
Lines of interest: line 73
client.js https://github.com/valkyrienyanko/io-game-v2/blob/master/public/scripts/client.js
Lines of interest: line 149 and 153
player.js https://github.com/valkyrienyanko/io-game-v2/blob/master/public/scripts/classes/player.js
Lines of interest: lines 29 - 38
Steps to Reproduce
Follow the setup to create at least 2 clients "A" and "B". Have clients side by side so you can see what's going on in both clients at the same time. In client A, press to open up the chat and type "foo", press again to send. Do the same for client B but this time say "bar". You should see the problem now.
Solved. Take a look at the commit --> 9bf8a95