Open AnotherDole opened 9 years ago
I've noticed that a little bit too. I was trying to think about if there was some sort of killswitch that could override the game flow...
Dealer deals to defender.
Defender defends statement.
-> All players wait for indication that defense is over
This has happened to me once, and I think this is where people are having issues is that they won't get this indicatio and then the whole game needs to be started over.
I wonder if (and this is just an idea), since the non defending players already have a timer themselves, if they could have a situation where their timer would go to -5 and it would force the round end.
The issue there is that if there's 5 players, 4 people would be sending this command at basically the same time.
As far as I can tell, what's happening is that players are losing connection to the server but the code on the server that's supposed to handle that isn't running. I'm really not sure why.
I could have the server enforce the time limits but that doesn't fix the main issue.
There's gotta be hiccups in the i/o connection, right? If one browser sends a 'this player is done' message, is there any sort of callback to verify that message has been received?
http://socket.io/docs/#sending-and-getting-data-(acknowledgements)
That individual browser can get confirmation that the message was received, but I'm not sure how that helps in this case if they've been disconnected but the disconnect event isn't triggering.
I know that the disconnect code isn't triggering properly because when I look through the database I can see that there are still entries for games and players that obviously are no longer active and should have been deleted. I have some guesses as to why this is but socket.io's documentation is really unclear about some stuff and I don't know how to reproduce what's happening.
Unfortunately here's where I reach the upper limit of my understanding of this stuff, because the server side messaging just never clicks with me.
Is it maybe possible to have some sort of "heartbeat" type thing that gets passed around the game, like "Hey, send me a 1 if you're still here." "1" "Okay, cool. Just checking."
I dunno, it seems like the back & forth messaging is getting dropped every once in a while, so maybe backups are necessary.
I'mma stop typing, I don't think I'm being helpful.
My understanding is that that sort of thing happens automatically under the hood and if a client fails to respond they should get disconnected. Doing it manually is an option I guess but it would be a pain. I know that clients automatically attempt to reconnect if there is an interruption in the connection but I don't think the socket.io documentation is clear on the order of events and what I can do server side to detect that it's happening.
I played with the server configuration a little and enabled some debug logging, so if it happens again hopefully I will have a better idea of what's going wrong.
Okay, wow. Caught this happening in the logs and it was something I was not expecting at all. I think I know how to fix it, at least.
This sounds like good news?
Well, I know what is happening even if I don't know why it is happening.
Think node is dropping the ball?
It's some weirdness with socket.io. Basically, here's what I'm seeing in the logs:
Player 1 joins the game via Socket 1.
Player 2 joins the game via Socket 2.
Player 3 joins the game via Socket 3.
Player 4 joins the game via Socket 4.
Player 5 joins the game via Socket 5.
Everything's fine up to this point.
Player 1 on Socket 1 leaves the game.
Again everything fine here. But then...
Player 1 joins the game via Socket 2.
Uh, what? Where did player 2 go and why is player 1 suddenly using their socket?
Since player 2 didn't get properly disconnected, they are still in the database even though there is no longer a socket associated with them. So when it comes to be their turn to do something, the game just locks up because no one can control player 2 anymore.
Reopened this due to the thread on ballp.it. I've added an indication that you've been disconnected and that you've been reconnected. The thread also reported that they could not re-use the same name after being disconnected, but I can't reproduce this.
Apparently people have been having connection issues that have been preventing them from finishing games? I have some ideas for what's going wrong but I can't know for sure unless people actually tell me what's happening.