Search Unity

Third Party How to do refresh on Photon Engine (PUN 2)

Discussion in 'Multiplayer' started by KICKpriodact, Nov 24, 2021.

  1. KICKpriodact

    KICKpriodact

    Joined:
    Aug 22, 2021
    Posts:
    7
    HI!
    void OnRoomListUpdate working when OnConnectedToMaster and JoinLobby , but I want update list when i click on the button
    I need to call again somehow void OnConnectedToMaster to refresh my list
    How can i do this?


    Code (CSharp):
    1.     public override void OnRoomListUpdate(List<RoomInfo> roomList)
    2.     {
    3.         foreach (RoomInfo info in roomList)
    4.         {
    5.             for (int i = 0; i < allRoomsInfo.Count; i++)
    6.             {
    7.                 if (allRoomsInfo[i].masterClientId == info.masterClientId)
    8.                     return;
    9.             }
    10.  
    11.             if (info.RemovedFromList)
    12.             {
    13.                 int index = RoomList.FindIndex(x => x.RoomInfo.Name == info.Name);
    14.                 if (index != -1)
    15.                 {
    16.                     Destroy(RoomList[index].gameObject);
    17.                     RoomList.RemoveAt(index);
    18.                 }
    19.             }
    20.             else
    21.             {
    22.                 RoomList roomListCount = Instantiate(roomListButton, content);
    23.  
    24.                 if (roomListCount != null)
    25.                 {
    26.                     roomListCount.SetInfo(info);
    27.                     allRoomsInfo.Add(info);
    28.                     RoomList.Add(roomListCount);
    29.                 }
    30.             }
    31.         }
    32.     }
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    By design, you can't fetch the room list.
    Networking wise it's much better to send updates and those are done in intervals.
     
  3. KICKpriodact

    KICKpriodact

    Joined:
    Aug 22, 2021
    Posts:
    7
    How I can send updates and those are done in intervals?
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    Start here: PUN Basics Tutorial. Read and code-along.
    The rest of the docs will be of interest, too.
     
  5. KICKpriodact

    KICKpriodact

    Joined:
    Aug 22, 2021
    Posts:
    7
    I read this and not found information how to send updates for void OnRoomListUpdate
     
  6. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    By design, you can't fetch the room list.
    Join a lobby (which is a list of rooms in Photon terms) and you get the updates in intervals.
     
  7. KICKpriodact

    KICKpriodact

    Joined:
    Aug 22, 2021
    Posts:
    7
    Thank you, I found what my problem is.
    It consisted in the fact that my code stopped and no updates occurred!
    I LOVE U AND PHOTON!
     
    Last edited: Dec 10, 2021
    tobiass likes this.