OnRoomListUpdate() won't show existing lobby if user started session after lobby was created?

DevCam
DevCam

Hello,

Currently, I have lobbies working for when both sessions are running at the same time. However, if one session hosts while the other session is not on the game, once the play starts the game the created lobby doesn't populate?

Here's my code:

Dictionary<string, RoomInfo> cachedRoomList = new Dictionary<string, RoomInfo>();

  private void Update()
  {
    lobbyCount.text = "Lobbies: " + PhotonNetwork.CountOfRooms;
    onlineCount.text = "Online: " + PhotonNetwork.CountOfPlayers;
  }

  private void UpdateCachedRoomList(List<RoomInfo> roomList)
  {
    for (int i = 0; i < roomList.Count; i++)
    {
      RoomInfo info = roomList[i];
      if (info.RemovedFromList)
      {
        cachedRoomList.Remove(info.Name);
      }
      else
      {
        cachedRoomList[info.Name] = info;
        GameObject createdServer = Instantiate(serverRow, serverContent.position, serverContent.rotation);
        createdServer.transform.parent = serverContent;
        createdServer.transform.localPosition = new Vector2(0,-60);
        createdServer.transform.Find("Name").GetComponent<Text>().text = info.Name;
      }
    }
  }

  public override void OnJoinedLobby()
  {
    cachedRoomList.Clear();
  }

  public override void OnRoomListUpdate(List<RoomInfo> roomList)
  {
    Debug.Log("Ran");
    UpdateCachedRoomList(roomList);
  }

  public override void OnLeftLobby()
  {
    cachedRoomList.Clear();
  }

  public override void OnDisconnected(DisconnectCause cause)
  {
    cachedRoomList.Clear();
  }

Answers

  • JohnTube
    JohnTube ✭✭✭✭✭

    Hi @DevCam,

    Thank you for choosing Photon!

    It's not clear to me what the issue is.

    But in general I recommend going through our Matchmaking Checklist.

  • Hi @JohnTube

    Sorry, it is kind of hard to explain the situation. Let me try to explain it better:


    Say there are two people:

    Player 1 starts his game first and clicks Host Server. The room has now been created

    Player 2 now starts his game. He goes to view the list of servers. However, the room Player 1 created won't show because OnRoomListUpdate() doesn't fire if Player 2 isn't on the game at the same time that Player 1 created the room.


    Does that make sense? Let me know.

    Thanks!