Can't join existing room in LoadBalancing

Options
eyewitness4560
edited June 2013 in Photon Server
We are trying to build a system on LoadBalancing, inwhich when a user is automatically put in the room he disconnected from.

We got so far as to verify the user, and getting the room id from his segment of the DB. After this the system checks to verify if the room exists or not. If it exists, it logs him in, if not it creates the room.

The problem is, that sometmes, when we enter the room with the first test user, and the room is created, upon trying to log in with the second test user, the system says the room is not created yet, so tries to create anoter one. But since the room that the system wants to create alredy exists (in the second check of load balancing's create room), it throws an exception. When we try to list the rooms, we can see that the room list updates, and sometimes we can't see rooms that are alredy created and have players in them. The rooms have not been locked, are not full, and are visible.

Cliffnotes: HandleJoinGame says there's no room, calls HandleCreateGame says there is a room, even though there's someone in the room alredy.

Any tips for making the rooms available all the times? Or are we going about this the wrong way?
Thanks in advance :)

Comments

  • Hello,

    the problem is most likely that the room can only be joined by a second client when it was created on the Game Server. As long as the first peer did not "arrive" at the GS, your workflow will fail - like this:

    Client 1 -> Create Room on Master
    Client 1 -> Disconnect from Master
    Client 2 -> Join Room on Master // fails because room doesn't exist on GS yet
    Client 2 -> Create Room on Master // fails because room name is already "reserved" by Client 1
    Client 1 -> Create Room on Game Server
    GS -> notify Master that Room was created
    Client 1 -> Join Room on Master (would succeed)

    For now, there are basically two options:
    - modify the implementation of JoinRoom to wait longer until a room was found (i.e., until it was created on the GS)
    - retry another JoinGame with client #2 after "CreateGame" failed

    We have been aware of that problem as well, and we have modified the JoinGame operation so that it will have a parameter "CreateIfNotExists" in future. This makes matchmaking easier, but it has the drawback that you can not pass any room properties (because you don't know in advance if you are the one who creates the room or if someone else has already created the room and set the properties).

    The change will be part of our next Server SDK (+ related Client SDKs) release, but unfortunately, I can not yet announce a date for it - sorry.
  • It totally worked :D

    We modified your suggestion a bit, to include both;
    Check if room exist.
    If not, then try to create, and relay the result from the creation.
    If the client determines that the room can't be created because it alredy exists, then it waits for the server's answers (updated room list).
    Upon getting it, with the requested room in it, it connects without a problem.

    Thanks again, Nicole :)
  • Cool, thanks for the update! :)