SQL Matchmaking doesnt put players in same room

Options
I'm currently trying to use SQL matchmaking however whenever I have two clients running, they never seem to join the same game. They should connect to the same game since the server sql string is the same as the room settings!
Here is my code:

This method is called within OnConnectedToMaster().
void MakeSqlMatchmakingJoinAttempt()
    {
        if (joinAttempt < maxSkillDeviation)
        {
            string sqlLobbyFilter = "( C0=1 )";
            
            PhotonNetwork.JoinRandomRoom(null, 4, ExitGames.Client.Photon.MatchmakingMode.FillRoom, newLobby, sqlLobbyFilter);
            
            joinAttempt++;
            Debug.Log("Attempt failed.. trying again.");
        }
        else
        {
            Debug.Log("No rooms found. Creating Room");
            CreateSqlMatchmakingServer();
        }
    }
When game attempts to join room:
void MakeSqlMatchmakingJoinAttempt()
    {
        if (joinAttempt < maxSkillDeviation)
        {
            string sqlLobbyFilter = "( C0=1 )";
            
            PhotonNetwork.JoinRandomRoom(null, 4, ExitGames.Client.Photon.MatchmakingMode.FillRoom, newLobby, sqlLobbyFilter);
            
            joinAttempt++;
            Debug.Log("Attempt failed.. trying again.");
        }
        else
        {
            Debug.Log("No rooms found. Creating Room");
            CreateSqlMatchmakingServer();
        }
    }
When creating Matchmaking Room
void CreateSqlMatchmakingServer()
    {
        RoomOptions newRoomOptions = new RoomOptions();

        newRoomOptions.isOpen = true;
        newRoomOptions.isVisible = true;
        newRoomOptions.maxPlayers = 4; //alter this for game mode type.

        //C0 = Map
        //C1 = Mode (2v2,3v3)
        //C2 = Skill level
        newRoomOptions.customRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "C0", 1 } };
        newRoomOptions.customRoomPropertiesForLobby = new string[] { "C0" };
        Debug.Log("Custom props: " + newRoomOptions.customRoomProperties);
        
        PhotonNetwork.CreateRoom(Random.Range(0, 10000).ToString(), newRoomOptions, newLobby);
        
    }
please help!!!!

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Tubbly,

    I guess you're using SQL Lobby type (newLobby.Type = LobbyType.SqlLobby).
    Are you trying to join a room when another player is already in it or you're expecting rooms to stay in the lobby even when empty?
    Try changing the SQL filter string to "C0 = 1".
  • Tubbly
    Tubbly ✭✭
    edited February 2016
    Options
    Yeah in Start() I have
    newLobby = new TypedLobby("ChampionBrawlLobby", LobbyType.SqlLobby);
    newLobby.Type = LobbyType.SqlLobby;
    and I have two clients running, I will create a room in one client, then when the second client tries to join a game, it doesn't recognize a game has already been created by the first client and creates another room. So in the end there are two rooms, both with one player in them :( instead of the desired two players in one room. I've also tried to use "C0 = 1" no luck
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Please can you tell us which PUN version do you use?
  • Tobias
    Options
    Please make sure your clients are on the same server and use the same virtual app (region, appid, GameVersion and PUN version must match). But I assume it's the same build in your test case.

    Also make sure the first client created the room a moment before the second searches for it.

    If you use an older PUN version, please update. We figured out that Unity has a little bug with C# properties. When we didn't use a backup field, they were not assignable as the demo code shows (with curly brackets)...
  • Tubbly
    Options
    I'm on version 1.66 according to the Changelog.
    I'm also just building the game and running the same client twice so region, appid, game version and PUN versions must match. (Same build.)

    I also waited 10 seconds before running the second client.
  • Tobias
    Options
    We could not reproduce the issue yet. We checked if the brackets in your "where" clause are OK for Photon, checked other variations, etc. It all works fine, as far as we can see.

    I can't see how your code decides that you couldn't join a room. You just state it failed, directly after calling JoinRandomRoom(). I hope you do realize this takes a roundtrip and PUN either calls OnPhotonRandomJoinFailed() or OnJoinedRoom() eventually?
  • Tobias
    Options
    Actually, I used your code in our scripts (rough, quick copy paste job) and it worked for me.
    Check this: http://pastebin.com/RTN0y8fu

    In doubt, please change the GameVersion before you try again. Maybe you used C0 for a string value first, then switched to numbers. This would confuse our server about the type of values you intend to use.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Tubbly,

    In your first post there is a duplicate code block MakeSqlMatchmakingJoinAttempt. Is this intended? Do you call it in both cases? ("within OnConnectedToMaster()" and "when game attempts to join room").

    Sometimes the issue "is not what we think it is". How do you initialize and reset joinAttempt and maxSkillDeviation?
  • Tubbly
    Options
    JohnTube said:

    Hi @Tubbly,

    In your first post there is a duplicate code block MakeSqlMatchmakingJoinAttempt. Is this intended? Do you call it in both cases? ("within OnConnectedToMaster()" and "when game attempts to join room").

    Sometimes the issue "is not what we think it is". How do you initialize and reset joinAttempt and maxSkillDeviation?

    the duplicate code block was actually a mistake, I never noticed that lol, I think I pasted it in twice. I've now resolved the issue using Tobias' pastebin example. Working great now! Thanks for the support!!
  • Tobias
    Options
    Good to know you could make it work.
    Did you analyze what went wrong originally? Can you let us know?