Client and Photon condition lag case problem

Hi guys, I have a case problem that i'd like to share

Let say a host successfully created a room. For 10 seconds waiting for random client to join the room.
After 10 second, the host will call close room.

What close room doing is
InternalLoadBalancingClient.CurrentRoom.IsOpen = false;
move to another scene/page

And here is the problem,
just before "close room" process is called, the host has connection problem for a second.
so the host cannot send the edited room properties and make the photon to refuse player to joining the room.
In these time interval, photon receiving other player request and let the player joining these host's room.
After a second, host has the connection back and of course close room request is resent by the photon plugin, but in the same time I doubt photon send joining event so make my app is running "join player" event after "close room".

I think I can insert a validation in "join player" something like if room is closed then return. And the opposite for "close room".
But, I think below is best algorithm to choose and I want to do this
close room () {
InternalLoadBalancingClient.CurrentRoom.IsOpen = false
WaitUntilNextTwoACK (() => {
if(player not joined yet) {
move to another scene
} else {
do nothing (let the matching process to continue)
What I expect by wait until next 2 ACK is, let the photon to process CurrentRoom.IsOpen:false and refuse the joining player to the room, even there is connection problem is occurring, the next 2 ACK is the correct time to closing the room.
By doing this algorithm, I think I don't need to worry about "join player" process.

Why need 2 ACK?
first ACK is to confirm room.IsOpen:false is sent to photon server
second ACK is to confirm that is updated condition and events is from IsOpen:false condition

And here's my question,
How can I know an ACK is successfully received?

*I don't really have knowledge about ACK behavior, I think that ACK is included in server response to confirm that information is successfully passed
*Please tell me if I make something wrong in this post


  • JohnTubeJohnTube mod
    edited January 2018
    Hi @Jho,

    Thank you for choosing Photon!

    Let's not go down the "infinite ACKs road"...

    So you are worried that a client tries to "close" a room but before this reaches the server and succeeds another player joins the room.
    This is tricky to avoid using basic client operations.

    May I ask at which point do you "close" rooms?

    Maybe you can change how you do matchmaking or make use of other Photon features:

    - set MaxPlayers and ExpectedUsers to also restrict players from joining
    - create rooms "invisible" (IsVisible = false) to disallow random join
    - leave rooms when you know you are not allowed to join it (or you join it too late)...

    I also wanted to let you know that you can listen for a specific occurrence (based on event content or property key/value) of the event PropertiesChanged in OnEvent callback which is considered the ACK for closing the room. So using this you can know that/when the room has been closed successfully.
  • @JohnTube, Thank you for replying my discussion post!

    Sorry I don't understand what you mean with "which point".

    But, I see!
    I can create new OnEvent callback for closing room!
    Change the room property then send the "closing room" event.
    When the "closing room" event is came, the condition is just like what I want.
    I think I can use this method!

    Thank you very much!!
Sign In or Register to comment.