Notify on refresh

Game development with Board Game Arena Studio
User avatar
JudgeWhyMe
Posts: 36
Joined: 08 August 2012, 17:14

Notify on refresh

Post by JudgeWhyMe »

Hello

How can I send a notification to other players when one player refreshes their page (through F5 for instance)?

Player 1 is in State1, performs some actions on client side that impact other players but does not change state, then refreshes their page. Other players must be warned in order to cancel the impact previously made.

I tried to send it in the stState1 method, in the argState1 method, but it does not work, no notifications are sent.

Thanks
User avatar
RicardoRix
Posts: 2541
Joined: 29 April 2012, 23:43

Re: Notify on refresh

Post by RicardoRix »

It sounds like you are perhaps missing out sending onEnteringState() (or setup()) data to the player that pressed F5 so they return to their own client state.
So for example a player is half way through their turn and they have moved a green piece to a new position, and you showed this to other players, then now after any player does an F5, they need to see the green piece in the new position.

note it's fine if nothing was shown to other players, then the active player hits F5 then that would perhaps take them back to an initial position. Like they might be half way though a series of action button selections or something and not yet committed. F5 refreshing here is ok to go back to the initial position.

F5 should not change any game state, so that does not need to be a consideration. The server is the ruler of the game state and giving out notifications.
User avatar
JudgeWhyMe
Posts: 36
Joined: 08 August 2012, 17:14

Re: Notify on refresh

Post by JudgeWhyMe »

I'm not sure I undertand the answer, maybe I asked the wrong question, I'll try again:

Player 1 is in a state StateA requiring 2 clicks:
- first click makes a green piece appears
- seccond click makes a blue piece appears

Player 1 performs the first click, a notification is sent to everyone, so player 1 and 2 both see the green piece appears on their board

Then player 1 hits refresh. He goes back to the start of the state, where there was no green piece. During the setup, the green piece does not appears on their board. How do I make the green piece disappears on the other player board? I tried to send notifications to player 2 during stStateA and argStateA, no notification is received by player 2

I need this behaviour because players are in private parallel states. As soon as there is a green piece on the board, player 2 cannot make a green piece appears. And if player 1 cancels its first click (either by clicking on an undo button or hitting refresh), player 1 can make a green piece appears.

Thanks
User avatar
RicardoRix
Posts: 2541
Joined: 29 April 2012, 23:43

Re: Notify on refresh

Post by RicardoRix »

JudgeWhyMe wrote: 14 August 2025, 06:39 Then player 1 hits refresh. He goes back to the start of the state, where there was no green piece.
so now on the refresh, you need to put the green piece back to where it should be.
User avatar
JudgeWhyMe
Posts: 36
Joined: 08 August 2012, 17:14

Re: Notify on refresh

Post by JudgeWhyMe »

Exactly. And how can I notify the other player (the on that didn't refresh) to put the green piece back where it should be? That's my problem, I don't find a way to do that
User avatar
AxeCrazy
Posts: 90
Joined: 15 March 2014, 01:07

Re: Notify on refresh

Post by AxeCrazy »

This can be done in the onUpdateActionButtons i guess.
User avatar
RicardoRix
Posts: 2541
Joined: 29 April 2012, 23:43

Re: Notify on refresh

Post by RicardoRix »

JudgeWhyMe wrote: 14 August 2025, 10:48 Exactly. And how can I notify the other player (the on that didn't refresh) to put the green piece back where it should be? That's my problem, I don't find a way to do that
You don't need to. The green piece is already in the new (correct) position. The only person who doesn't know is the person that has just refreshed. You need to do that, not worry about the other players who didn't refresh.

for anyone who refreshes put the green piece in the new position.
Last edited by RicardoRix on 14 August 2025, 12:01, edited 1 time in total.
User avatar
thoun
Posts: 1620
Joined: 10 December 2020, 22:25

Re: Notify on refresh

Post by thoun »

If you have an issue on refresh, it's not a notification issue, but probably something missing in the getAllDatas.
Maybe give the project name, so we could see if there is something wrong in the state design.
User avatar
JudgeWhyMe
Posts: 36
Joined: 08 August 2012, 17:14

Re: Notify on refresh

Post by JudgeWhyMe »

You don't need to. The green piece is already in the new (correct) position. The only person who doesn't know is the person that has just refreshed. You need to do that, not worry about the other players who didn't refresh.
The green piece is not in the correct position. Player 1 refreshes in the middle of State A. The refresh action means that the green piece should be removed, put back at the initial place it was at the beginning of Player 1's turn. So actually Player 1 is the only who has the correct information. The other players saw the green piece as it was when Player 1 refreshes, not as it was at the beginning of Player 1 turn.

I want the other player to somehow detect or be informed that player 1 refreshes their page to put back the board as it was at the beginning of player 1's turn
User avatar
Tisaac
Posts: 2736
Joined: 26 August 2014, 21:28

Re: Notify on refresh

Post by Tisaac »

JudgeWhyMe wrote: 14 August 2025, 15:47
You don't need to. The green piece is already in the new (correct) position. The only person who doesn't know is the person that has just refreshed. You need to do that, not worry about the other players who didn't refresh.
The green piece is not in the correct position. Player 1 refreshes in the middle of State A. The refresh action means that the green piece should be removed, put back at the initial place it was at the beginning of Player 1's turn. So actually Player 1 is the only who has the correct information. The other players saw the green piece as it was when Player 1 refreshes, not as it was at the beginning of Player 1 turn.

I want the other player to somehow detect or be informed that player 1 refreshes their page to put back the board as it was at the beginning of player 1's turn
Just do the same as you did for the first part of the action. You sent a notif to move the position for others, just do the same when they cancel their turn
Post Reply

Return to “Developers”