Dealing with disconnected players

Game development with Board Game Arena Studio
Post Reply
DexterHugo
Posts: 17
Joined: 11 April 2020, 15:48

Dealing with disconnected players

Post by DexterHugo »

Hi, I'm hoping there is something documentation wise that I'm just missing, but let's say a player puts their computer to sleep with the game open, other players take their turns overnight and then the player wakes their computer the next day.

How can I tell that the player is out-of-sync with the game, and once I know that, can I force reload the game for them, or do they have to refresh?

Off the top of my head, I thought the simplest would be to keep a lock-step variable that I check - server is on step 30 and client is on step 20-return an error that they need to refresh. I also thought maybe that's what the game progression could do (if it deals with fractions so 28.53% vs 28.59% since a 100 steps probably isn't going to be enough). Ideally too, instead of checking it with every move, maybe I run a special check when the message "you are connected" appears (if there is a hook into that?)?

What's the best practice for it? Thanks!
User avatar
robinzig
Posts: 459
Joined: 11 February 2021, 18:23

Re: Dealing with disconnected players

Post by robinzig »

Not sure what you mean, but BGA handles all this sort of thing itself - many times I go back to a game in a tab where there's been no activity for a few hours, where it tells me I'm disconnected and basically force refreshes the page.

The developer of an individual game adaptation doesn't have to worry about it.
DexterHugo
Posts: 17
Joined: 11 April 2020, 15:48

Re: Dealing with disconnected players

Post by DexterHugo »

Ah-maybe it was just a weird glitch I was in this morning. I was testing last night in Safari on my Mac, closed the lid - jumped on my iPad to test and then this morning woke up and opened my computer and noticed the 3 events I did on my iPad weren't logged in Safari after reconnecting, and my game was in a spot where I could do something that wasn't synced with what I already did. So that's what took me down that path.

I will say-it's probably an odd edge case as I was still the active player and I was still in the same game state. So probably just something off about how that was playing together at that moment??

I wonder though - maybe I did something wrong with my state handling. This is where I was at:

In the game, each player has 3 action cubes that they place on their turn to main board to declare actions.

Iteration 1: I setup the game state "placeCubesAction" to allow the player to place all of their cubes as well as undo the placement, and then send the final result to the server to record and broadcast.

Iteration 2: I thought it would be more interactive if the other players could "see" each individual cube being placed (and/or undone) - so I made calls to place the cubes, record the move in the DB and notify other players. However, I stayed in the same game state until the player places all 3 cubes and clicks a final confirm turn button.

So maybe since the game state didn't advance, the system didn't force a refresh? I'll verify later by trying different game states. Also-I haven't implemented game progression yet, so I wasn't sure if it was that or something else that I need to do report the correct progression?
Post Reply

Return to “Developers”