Player entered and left room repeatedly sometimes

It's a two player room game, I tested it using 2 devices. 1st device play as server, and after the 2nd player tried to join the updated session, occasionally, if failed. Then I let the 2nd device tried to join the updated session again, that's when this "bug" happened. The 2nd player entered and then instantly left the room, then entered and left repeatedly, as the following log shows:
[12:00:02] Player 3 entered the room
UnityEngine.Debug:Log (object)

[12:00:03] Player 3 has left the room, current master client is 1
UnityEngine.Debug:Log (object)

[12:00:08] Player 4 entered the room
UnityEngine.Debug:Log (object)

[12:00:09] Player 4 has left the room, current master client is 1
UnityEngine.Debug:Log (object)

[12:00:14] Player 5 entered the room
UnityEngine.Debug:Log (object)

[12:00:15] Player 5 has left the room, current master client is 1
UnityEngine.Debug:Log (object)

My game works well usually, and this happened just a few times. What could possibly be the problem and how can I prevent this or catch this situation(like an exception or call back) so I could deal with it?

Comments

  • Hi,

    - What do you mean by "updated session"?
    - Are you trying to join a session from inside a loop? Maybe inside the "SessionListUpdated" callback? If yes, are you controlling the attempt state somehow? For example, "Idle", "StartingJoin", "Joined", "FailedToJoin", in order to control further attempts to join a session?
    - Are you using Auto or Manual AcceptMode?

    --
    Ramon Melo
    Photon Bolt Team
  • Thanks for replying @ramonmelo
    - By "updated session" I mean trying to join a session inside the "SessionListUpdated" callback.
    - I didn't try to join a session in a loop(except for looping through the sessionlist and find the 1st valid one to join, just as the example project in docs show). I don't control the the state and I didn't write any codes for further attempts to join a session. I thought the constant trying was automatically done by Bolt.
    - I use Manual Accept mode. While I'm wring this I have checked my codes of "ConnectRequest" on server, I think I might found out what causes the problem. I have a bool flag to indicate whether if the room is full. When the first time the 2nd player joined, the flag was set to true. Then not sure why it left the room. Then Bolt attempted to join the session again. But since the flag is true, it was refused under "ConnectRequest". Then causing what described above.

    The reason I use that flag is to prevent that when 2nd player lost connection, then this room won't be joined by any other players. So what I should do now is to close the session under "Disconnected" callback on server, am I right?