Client.opGetRooms() seems to always result in 0

So yes I know other questions were already asked about the exact same problem but it seems that those questions were both for C# and not really helping me out as I tried everything mentioned.

So I have the client that connects to the server and on connecting, will join the lobby "Main". Now when I create rooms, I make sure to set them as visible and the lobby to be "Main". And seeing as AutoJoinLobby is set to true by default I don't think I need to worry about joining the lobby every time I leave a game room.

But for some reason even having multiple clients in their own rooms (that should be connected to the "Main" Lobby), Client.opGetRooms() still gives 0 rooms.

Does anyone know why this is happening?

Best Answer

  • Kaiserludi
    Kaiserludi admin
    Answer ✓

    Hi @StereoJunkie.


    The 'autoJoinLobby' flag makes the clients join the default lobby. If you want to join your 'Main' lobby instead, then you need to turn off 'autoJoinLobby' and explicitly join the 'Main' lobby each time you leave a room.


    The is no function with the name opGetRooms() anywhere in the Photon Client. I assume that you mean Client::opGetRoomList(). Is that correct?

    As pointed out in the API reference for Client::opGetRoomList(),  that function is only available for lobbies of type SQL_LOBBY, so if 'Main' is of a different lobby type, then that operation won't work for 'Main'.

    Also please note that Client::opGetRoomList() does not require the client to be inside a lobby at all. Being connected and not inside the room or in the process of entering or leaving a room is all that is required to use that operation.

    If you want to receive the list of rooms that are currently available in a lobby of type DEFAULT, then you need to join that lobby and wait for the room list events, which will arrive automatically. Lister::onRoomListUpdate() gets called whenever such an update arrives. Afterwards you can call Client::getRoomList() to receive the latest room list for the lobby in which the client is in.

Answers

  • Kaiserludi
    Kaiserludi admin
    Answer ✓

    Hi @StereoJunkie.


    The 'autoJoinLobby' flag makes the clients join the default lobby. If you want to join your 'Main' lobby instead, then you need to turn off 'autoJoinLobby' and explicitly join the 'Main' lobby each time you leave a room.


    The is no function with the name opGetRooms() anywhere in the Photon Client. I assume that you mean Client::opGetRoomList(). Is that correct?

    As pointed out in the API reference for Client::opGetRoomList(),  that function is only available for lobbies of type SQL_LOBBY, so if 'Main' is of a different lobby type, then that operation won't work for 'Main'.

    Also please note that Client::opGetRoomList() does not require the client to be inside a lobby at all. Being connected and not inside the room or in the process of entering or leaving a room is all that is required to use that operation.

    If you want to receive the list of rooms that are currently available in a lobby of type DEFAULT, then you need to join that lobby and wait for the room list events, which will arrive automatically. Lister::onRoomListUpdate() gets called whenever such an update arrives. Afterwards you can call Client::getRoomList() to receive the latest room list for the lobby in which the client is in.

  • I see thank you, it wasn't clear in the docs that it should be called after Listener::onRoomListUpdate() event. Also I meant Client::getRoomList(), my bad for naming the wrong function.

  • Does calling Client::getRoomList() mean you have to wait for Listener::onGetRoomListResponse()?

  • No.

    getRoomList() instantly returns the current list of rooms. It just returns a reference to the local room list cache that gets updated by Listener::onRoomListUpdate().