OnRoomListUpdate not being called

Options
Hi everyone,

After I join a region and create a room TypedLobby.Default, the room doesn't show on the second instance, even though the second instance is on the same region. The fuction OnRoomListUpdate doesn't run.


https://imgur.com/a/2EhPzeU

How can I fix this?

Many thanks,
Gabriel.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @LuckBringer,

    Thank you for choosing Photon!

    Make sure you are using the same AppId, AppVersion and PUN version on both clients.
    Also double check the region as if one client is using development build and the other is not could lead to two different regions (dev region vs. fixed region vs. best region).
  • Hi John!

    I tried what you described and unfortunately didn't work. Both instances were playing with the same AppId, Pun version and same region.

    What type of troubleshooting should I do next, please?

    Many thanks,
    Gabriel.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @LuckBringer,

    Is the room you created visible?
    Check "AppStats and LobbyStats".
    OnRoomListUpdate works only when joined to the lobby of default type make sure the client is joined to such lobby and not disconnected and not in a room.

    Unrelated notes:
    If you extend MonoBehaviourPunCallbacks no need to implement ILobbyCallbacks.
    Make sure to follow our example snippet for how to handle rooms list as the callback could contain entries for removed rooms (roomInfo.RemovedFromList == true).
  • Hi John!

    I tried to do as you said I believe, even leaving a code after I joined to room to leave it open and visibie as you can see here:
    https://imgur.com/a/cTnF8pw

    And this is how I create a room:
    https://imgur.com/a/QFUnZt4

    Anything else I can try?

    And thanks for the tip at the end =)

    Thanks again John!
    Gabriel.

  • Oh and one more thing, when I used PhotonNetwork.CountOfRooms, it was able to find 1 Room, but not able to list it.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited February 2021
    Options
    I really don't see why is this happening.
    In the class that implement OnRoomListUpdate make sure to call base methods if you override OnEnable or OnDisable. Make sure that script is in the scene hierarchy enabled and attached to an active GameObject.

    I see you print/log the Region in some callbacks, maybe add PhotonNetwork.NetworkingClient.AppVersion also.
    Otherwise, enable SupportLogger and share (complete) logs from both instances.
  • Hi John,

    First of all, I did not understand what you said:
    "In the class that implement OnRoomListUpdate make sure to call base methods if you override OnEnable or OnDisable."

    Could you please explain it to me?


    ___________________________________________________________________________________________________

    This is the log of the first instance:
    https://imgur.com/a/QnNEyOS

    This is the second one:
    https://imgur.com/a/ogGFT2M

    (I'm using sandboxie to use 2 editors at the same time, sandboxie is a software that allows the user to open any software in a complete closed part of your hard drive, just in case you find strange that I'm sending 2 pictures from Unity Editor)

    And as you can see, the second instance can even find that there is one Room with the CountOfRooms, but it doesn't run the function OnRoomListUpdate.



    And I am able to connect 2 players together if I just let them join a random room, as you can see from the gameplay from my game:
    https://www.youtube.com/watch?v=XJld6gyifpA&ab_channel=InitiativeVR

    Just the listing of the rooms that isn't working.

    Many thanks once again,
    Gabriel.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @LuckBringer,

    Sorry for the delay on this one.
    In the class that implement OnRoomListUpdate make sure to call base methods if you override OnEnable or OnDisable.

    if you have a class that extends MonoBehaviourPunCallbacks and implement OnEnable or OnDisable methods you must override them and call base methods:
    public class SomeClass : MonoBehaviourPunCallbacks 
    {
        public override void OnEnable()
        {
                 base.OnEnable();
        }
        public override void OnDisable()
        {
                 base.OnDisable();
        }
     }
    

    As I can see SupportLogger.OnRoomListUpdate was called successfully so OnRoomListUpdate that you implemented is not called probably because of an issue in your code or your project. I'm sure it's something silly and tiny that you overlooked.

    Also check that the component implementing it is enabled and attached to an active GameObject.
  • Hi John!

    Thanks for your reply again, I really have no idea what's going on.

    So the gameobject with the script is active, and you can see the setup through the link below:
    https://imgur.com/zZ1AcDm

    And this is the script with the code:
    https://imgur.com/a/FxNh8Wp

    As you can see, the second instance can recognize that there is a room, and even through they are on the same region, the OnRoomListUpdate method cannot find the room.

    What should I try next?

    Many thanks again, John
    Gabriel.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @LuckBringer,

    I want to re emphasize that SupportLogger.OnRoomListUpdate was called here (in a screenshot of the second client logs from a previous post).
    So from our point of view, everything works fine.

    What should I try next?

    - Check if you don't implement more than one OnRoomListUpdate in your scene and maybe one of them throws an unhandled exception that prevents further calls to the other remaining OnRoomListUpdate methods not called yet.
    If an unhandled (uncaught) exception occurs in one of the implemented interfaces' callbacks' methods, all other implemented ones for the same interface, same signature and not already called, won't be called. This is due to the fact that we call the implemented interface callback methods of the same signature in a loop in the order of their registration (which could be random in Unity if you register in MonoBehaviour methods).
    source

    - OnRoomListUpdate callback is a result of receiving one of two events: GameList (initial rooms list when joined to the lobby) or GameListUpdate (future updates to the initial list). This is handled inside LoadBalancingClient.OnEvent (Assets\Photon\PhotonRealtime\Code\LoadBalancingClient.cs) as you can see below:
    public virtual void OnEvent(EventData photonEvent)
            {
                // ...
                switch (photonEvent.Code)
                {
                    case EventCode.GameList:
                    case EventCode.GameListUpdate:
    
                        List<RoomInfo> _RoomInfoList = new List<RoomInfo>();
    
                        Hashtable games = (Hashtable)photonEvent[ParameterCode.GameList];
                        foreach (string gameName in games.Keys)
                        {
                            _RoomInfoList.Add(new RoomInfo(gameName, (Hashtable)games[gameName]));
                        }
    
                        this.LobbyCallbackTargets.OnRoomListUpdate(_RoomInfoList);
    
                        break;
    

    what you could do:

    - add logs there to see event is received
    - implement custom IOnEventCallback.OnEvent or LoadBalancingClient.EventReceived (PhotonNetworjk.NetworkingClient.EventReceived) event handled and check when/if client receives EventCode.GameList or EventCode.GameListUpdate.
    - attach Visual Studio Debugger to Unity and start debugging this.
  • Tobias
    Options
    It seems you are running a Unity alpha version (which is quite dated).
    Just for the fun of it, I would run the project in 2019.4.x in case.

    Let us know how Hamza's latest suggestions worked.
    You mailed us but I don't get what the latest status is...
  • Hi John and Tobias!


    Once again, thanks for your reply!

    I checked and I only have one OnRoomListUpdate in my scene.

    And I couldn't quite understand this part:

    "- add logs there to see event is received
    - implement custom IOnEventCallback.OnEvent or LoadBalancingClient.EventReceived (PhotonNetworjk.NetworkingClient.EventReceived) event handled and check when/if client receives EventCode.GameList or EventCode.GameListUpdate.
    - attach Visual Studio Debugger to Unity and start debugging this. "

    But I did add debugs here:
    https://imgur.com/a/TU7Q7H9

    And in the game it appeared this:
    https://imgur.com/a/IImT372

    And you also asked me in the email to test the Asteroid example, it also didn't work. No rooms were listed there.

    And I can't use a newer version of Unity unfortunately, because I use SteamVR and it doesn't work for never Unity versions.

    Regarding the lobby, I'm not doing anything to it I believe:
    https://imgur.com/a/TjfnomS

    When I create a room I use this:
    PhotonNetwork.CreateRoom("Room "+ roomListCount + 1 + ": Player level " + playerDataScript.level, options, TypedLobby.Default);


    In the email, you mentioned this: "Check if the MonoBehaviourPunCallbacks.OnEnable() is being called", how do I do that?

    (The players can connect to each other if they use JoinRandomRoom, not sure if this information helps)


    Once again, thanks for the help! This one is a tricky one!
    Gabriel.

  • Tobias
    Options
    you mentioned this: "Check if the MonoBehaviourPunCallbacks.OnEnable() is being called", how do I do that?

    As you did with the "After switch". Just add a debug line and make sure it shows. You need to make sure that your class for callbacks is actually registered to get those!

    By the way: As the "After switch" shows up, this means the client get the list of rooms just fine. For some reason, your behaviour does not get the callback. One more reason to make sure it's registered correctly for getting callbacks.

  • Hi Tobias!

    Thanks for the reply once again.

    Apologies, but I still don't understand "Check if the MonoBehaviourPunCallbacks.OnEnable() is being called", I tried searching on my project for a function called "MonoBehaviourPunCallbacks.OnEnable()", but found nothing, and researching on google doesn't show what this is it.

    Do you mean I have to add a debug on OnEnable of my RoomListingsMenu script to see if it is running? I did add a debug on void Start and it shows that it's being called:
    https://imgur.com/a/kzLMPuN

    Warmest regards,
    Gabriel.

  • Hey guys, it seems it's working.

    If I test with 2 different instances on the same computer, I can connect both instances with each other and play, however if I try to list the rooms, it doesn't work. But if it's on a instance from another computer, then the room will be listed.

    It's very strange that I was able to connect 2 instances on the same computer, but not list the room, it seems the issues has been resolved!

    Many thanks for the help Tobias and Hazem!
    Gabriel.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Thanks for the updated.
    Strange issue indeed.
    Maybe it's a timing issue: OnRoomListUpdate callbacks are triggered before the script is enabled (and callbacks class registered for that component).
  • LuckBringer
    edited February 2021
    Options
    Really strange indeed.

    At the end the solution was this, if everything else is working but the RoomList, test the second instance with another computer and if possible using another internet connection.
  • Tobias
    Options
    It should really not be that complicated. For me, it works without the effort.
    Maybe you give another Unity version a try?
    You could also check if the "Asteroids Demo" from the PUN 2 package behaves alike.
  • LuckBringer
    Options

    For anyone having the same issue, I did not find a solution, however I just used the Asteroid Demo and modified it to my needs, it's easier.