Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Third Party PUN PhotonNetwork.GetRoomList problem

Discussion in 'Multiplayer' started by NikoBusiness, Mar 16, 2015.

  1. NikoBusiness

    NikoBusiness

    Joined:
    May 6, 2013
    Posts:
    289
    i tried 2 diferent CreateRoom() methods and still i get roomlist of length 0
    i dont know what the problem is.i join the room normaly and playing it normaly i event run 2 rooms to see if there is the problem i still get roomlist of 0?isnt the created rooms registered autimaticaly to the lobby?
    create room code :
    Code (csharp):
    1.  
    2. PhotonNetwork.CreateRoom("", true, true, 10); //visible true open true
    3.  
    get room list code :
    Code (csharp):
    1.  
    2. void OnJoinedLobby()
    3.     {
    4.         Debug.Log("room length : " + PhotonNetwork.GetRoomList().Length);
    5. }
    6.  
    do i have to do something ells in order to add the room to the lobby? i f***ing waste 4 hours trying to solve it -.-
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,021
    The "Worker Demo" in PUN has a working implementation of a simple listing.
    The trick is most likely that you can't get the rooms list while being in a room. For various reasons, we don't distribute the room list to all game servers. You need 2 clients: One creates a room and the second stays in the lobby and shows the list.
     
  3. NikoBusiness

    NikoBusiness

    Joined:
    May 6, 2013
    Posts:
    289
    thats what i do, but then i found out that i need to call the PhotonNetwork.GetRoomList on another call back named : OnReceivedRoomListUpdate and not OnJoinedLobby
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,021
    Oh. Right.
    The room list is not immediately available when you joined the lobby. The initial list is in an update coming right after the OnJoinedLobby.
    We plan to have lobbies that don't have lists, so I can not delay the OnJoinedLobby until an update is there but I am sure I can add some doc and logged "hint" why the list might be empty still.
    Sorry for the wasted time.
     
  5. NikoBusiness

    NikoBusiness

    Joined:
    May 6, 2013
    Posts:
    289
    no problem tobiass you are great,you give your costumers very fast-good feedback!
     
  6. BadSeedProductions

    BadSeedProductions

    Joined:
    Dec 26, 2014
    Posts:
    144
    So whats the answer here? I cannot get rooms, players or anything
     
  7. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,021
    @BadSeedProductions: See above.
    You don't get a list when not in a lobby on the Master Server. In a room, the list is empty. In PhotonServerSettings, you can set "Auto Join Lobby" to true, to get in a lobby when you connect or leave rooms.
    For workflow reasons, PUN does not yet have a list ready when it calls OnJoinedLobby but updates to the list trigger calls to OnReceivedRoomListUpdate().
     
  8. Whiteleaf

    Whiteleaf

    Joined:
    Jul 1, 2014
    Posts:
    728
    If anyone finds this thread and is wondering why it's not working, this thread helped me. I wasn't connected to a lobby. Basically, check "Auto join lobby" in your photon settings, then you list the rooms with "OnJoinedLobby()". I have a refresh function that just finds all rooms and list them. You also need to check whether not the client is inside the lobby, instead of somewhere else.
     
    max29497696, chrisall76 and tobiass like this.
  9. Chintan-Kansagara

    Chintan-Kansagara

    Joined:
    Jul 16, 2016
    Posts:
    19
    HI Friends
    unity 3D games photonnetwork plugin used but i am game build and create room in phone and second create room in my pc but " OnJoinedLobby" function call and next to Getroom list get but RoomList "0" length show plz help me.

    code Here.
    public virtual void OnJoinedLobby()
    {
    List<RoomInfo> roomList = PhotonNetwork.GetRoomList().ToList();
    Debug.Log(roomList.Count);

    Debug.Log("room length : " + PhotonNetwork.GetRoomList().Length);

    RoomOptions roomOptions = new RoomOptions () { isVisible = true, maxPlayers = 20 };
    PhotonNetwork.JoinOrCreateRoom (roomName, roomOptions, TypedLobby.Default);
    Debug.Log ("Create Room");
    }
     
  10. TarkHiz

    TarkHiz

    Joined:
    May 8, 2018
    Posts:
    1
    uma teu problema é bem simples de resolver, primeiro se conecte ao Lobby depois faça a busca das salas que serão retornadas sem nenhum problema.. se conectar ao servidor não basta só ira aparecer se estiver conectado ao lobby..