Photon cloud join random room allows same user to join twice

Hi,

I'm trying to create a simple turn based game and have ran into a weird problem. I'm currently using photon cloud and have Facebook authentication enabled. I do assign LoadBalancingClient.UserId to their Facebook Id, assuming that those IDs provided by Facebook are unique. The maximum number of players I want in a room are 2. The game should have the ability to randomly join any available room that does not have the maximum number of players.


The room creator creates a room that is in a lobby of type LobbyType.AsyncRandomLobby. From the documentation and forums, I understand that AsyncRandomLobby rooms are kept active on the server for a while before they are destroyed, after the last player leaves the room.

This is how i create my rooms:
public string CreateTurnbasedRoom()
	{
		string newRoomName = string.Format("{0}-{1}", this.UserId, Guid.NewGuid().ToString()); 

		RoomOptions roomOptions = new RoomOptions()
		{
			MaxPlayers = MaxPlayers,
			PlayerTtl = int.MaxValue,
			EmptyRoomTtl = 5000,
			CheckUserOnJoin = true,
			
			//I do have room properties that I set here along with with a list of lobby properties.
		};

		this.OpCreateRoom(newRoomName, roomOptions, TypedLobby.Async);

		return newRoomName;
	}

Once I create the room, start the game and temporarily leave this room and look for a random room using:
public void JoinRandomRoom()
	{
		this.OpJoinRandomRoom(null, 0, MatchmakingMode.FillRoom, TypedLobby.Async , null);
	}

This player seems to join the same room that it just created before but with a different ActorId.

I do set RoomOptions.CheckUserOnJoin to true so that user with same UserId is not able to join a room twice. The documentation says
Activates UserId checks on joining - allowing a users to be only once in the room.

Turnbased rooms should be created with this check turned on! They should also use custom authentication. Disabled by default for backwards-compatibility.

I do not want the same player to join the room twice but is this the intended behaviour that a player can join the room twice? Or am I doing something wrong?

Any help would be greatly appreciated.

Comments

  • I have the same problem, I just posted a new topic here minutes after you did. Did you modify the default LoadBalancingAPI code to add the TypedLobby.Async or there was an update after 4.0.0.4 ?
  • I modified the default LoadBalancingAPI to include a new Async Type
    //Async lobby type
    public static readonly TypedLobby Async = new TypedLobby("async", LobbyType.AsyncRandomLobby);
    
  • @gursimran I think maybe this is because of how the player "temporarily leaves the room". I think the proper way to do it is to call OpLeaveRoom() without any argument which is equivalent to OpLeaveRoom(false). Check the comment of that override method, it says "//TURNBASED".
  • Well I've said in an early post that I have the same problem and I already started a separate thread but I want to add that I'm not sure that the Player changes his ActorNr when Rejoining the game. I think he keeps the same one. But I have a another concern.

    After noticing this strange behavior in random matching with the AsynRandomLobby type I started to compare the RoomName of the "supposed Random" room to a cached list, here's a snippet :
    public override void OnOperationResponse(OperationResponse operationResponse) {
            base.OnOperationResponse(operationResponse);// important to call, to keep state up to date
            switch (operationResponse.OperationCode) {
               case OperationCode.JoinRandomGame: // 225
                    if (operationResponse.ReturnCode == ErrorCode.NoRandomMatchFound) {
                        // no game found create one!
                        CreateTurnbasedGame();
                    }
                    else if (this.Server == ServerConnection.MasterServer) {
                        string gameId = (string)operationResponse.Parameters[ParameterCode.RoomName];
                        if (GamesListManager.Contains(gameId)) {
                            Debug.LogWarning(string.Format("Joining old game {0} not a new random one", gameId));
                        }
                    }
                    break;
               default:
                 break;}
    }
    

    Here's an output of an occurrence of the problem :
    Photon_Re_Join_Old_Game_12_20_AM_after_More_Than7hrs.png

    The thing is, I'm using this format to generate RoomNames for newly created Rooms:
    string.Format("{0}-{1}-{2}-{3}", CloudRegion, LocalPhotonPlayer.UserId, System.DateTime.UtcNow.ToString(), Random.Range(0, 1000).ToString("D4"));
    

    And as you can see in the attached image, the Room was created @3/6/2015 5:43PM ! But I can assure you the problem happened @3/6/2015 11:20PM, approximately 6hours later ! But PhotonCloud is supposed to keep TurnBased Rooms in AsyncRandomLobby when all players become inactive for 1hour only! So what's going on ? I started to think I should abandon the AsynRandomLobby and go back to the default one.

    I don't know if this is related but another weird thing happened the other day also, check this thread.
  • Sorry for the late reply.
    I hope I answer all questions. Please let me know if I missed some info.

    gursimran: It's unclear how you leave the room. Can you verify it's OpLeave(true) to "return later"?
    If you "abandon" a room, you can join it later on as new actor. The check if the userID is already in the room will not complain in that case.
    When you re-join a room, then your UserID must match the previous one and you get to use the same ActorNumber as before automatically. The server is clever and finds your number based on the UserID. Despite that, send some actorNumber so it the client also knows you attempt a re-join.
    We want to streamline the API for this workflow but at the moment, there's a lot of other stuff going on and it should work (our demos do).

    JohnTube: Are you sure you did a OpJoinRandomRoom() and only that? If you can confirm that a room sticks 6 hours and more in the Async Lobby, we will take another look. It should time out the room after 60 minutes.
  • @Tobias : Yes I'm sure, Rooms with LobbyType == AsyncRandomLobby persist more than one hour in Photon servers .