Search Unity

Third Party Photon + GetRoomList + SqlLobby

Discussion in 'Multiplayer' started by Aiursrage2k, Aug 28, 2014.

  1. Aiursrage2k

    Aiursrage2k

    Joined:
    Nov 1, 2009
    Posts:
    4,835
    Heres what i am trying to do. I am creating a room in Unity Photon by passing in room optiosn and sqllobby. That does work but when i try to call GetRoomList, its empty. Is there no way of getting the list of rooms?
    http://forum.exitgames.com/viewtopic.php?f=17&t=4829

    What I wanted to do was something like this, so that i would be able to show how many players were in a room with that gametype. But apparently getroomList does not work with the sqllobby type.
    Code (CSharp):
    1.         {
    2.             if(playersOnlineText)
    3.             {
    4.                 int playersInRoom = 0;
    5.                 RoomInfo[] roomInfo = PhotonNetwork.GetRoomList();
    6.                 int roomCount = 0;
    7.                 if(playersOnlineText)
    8.                 {
    9.                     playersOnlineText.text = "Connected to Photon";
    10.                 }
    11.                 for(int i=0; i<roomInfo.Length; i++)
    12.                 {
    13.                     if(roomInfo[i].open)
    14.                     {
    15.                         ExitGames.Client.Photon.Hashtable h = roomInfo[i].customProperties;
    16.                         int gameType = (int)h["C1"];
    17.                         if(gameType==Constants.getGameType())
    18.                         {
    19.                             roomCount++;
    20.                         }
    21.                     }
    22.                     if(playersOnlineText)
    23.                     {
    24.                         playersOnlineText.text = "Players in Room:" + roomCount;
    25.                     }
    26.  
    27.                 }
    28.             }
    Okay I solved it turns out all i had to do was set the autoJoinLobby to false
    PhotonNetwork.autoJoinLobby=false;

    And then add

    voidOnConnectedToMaster()
    {
    Debug.Log ("onConnectedToMaster");
    TypedLobbysqlLobby = newTypedLobby("MyLobby", LobbyType.SqlLobby);
    PhotonNetwork.JoinLobby(sqlLobby);
    }
     
    Last edited: Aug 28, 2014
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,067
  3. Aiursrage2k

    Aiursrage2k

    Joined:
    Nov 1, 2009
    Posts:
    4,835
    Are you sure because it seemed to work, or maybe I changed something.
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,067
    The SQL Lobby never shows rooms. Maybe you switched from the default lobby?
     
  5. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,067
    In the PhotonServerSettings you can check EnableLobbyStatistics. This allows the server to send you an event with the stats of lobbies in use and how many players and rooms there are.
    Implement ILobbyCallbacks.OnLobbyStatisticsUpdate and handle the callback while being in the Master Server.
     
  6. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,067
    There is nothing else to add, as far as I can tell.
    If you are stuck, explain your issue and what you tried.
     
  7. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,067
    Use the code tags (in posts). Makes it a lot easier to read.

    The lobbies don't exist unless there is a room belonging to the lobby. So you won't see much, if you only use one client.
    You can set EnableLobbyStatistics via the PhotonServerSettings config and using ConnectUsingSettings. Implement OptionalInfoCallbacks.OnLobbyStatisticsUpdate, to get the list of used lobbies (via callbacks).
     
  8. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,067
    I named the relevant APIs but don't have specific sample code, sorry.
    Check the docs and read the API manual for the methods and values.