How do i get the list of rooms available to join

Options
I want to get the entire list of rooms that are hosted with some properties for perfect match making
please help

Comments

  • Kaiserludi
    Options
    Hi @Harish_Kagale.

    Just make sure you are inside the lobby (if you have not set the autoJoinLobby flag to false, then you are inside the lobby when the client is connected and not inside any game room) and call getRoomList(), which returns a list of all visible open rooms. Each of those rooms contains all properties that have been specified to be listed in the lobby when that room has been created.
    However you could also just use opJoinRandomRoom() and pass the properties as filters for which a certain value must be set (the keays of those properties need to be specified as listed in the lobby for this to work properly).
  • Harish_Kagale
    Options


    Hi Kaiserludi,

    Thanks for the quick reply.

    Wanted to explore if we could use opJoinRandomRoom() to make match making more efficient.
    We want to do match making with users who has the closest XP level and shields in specifc range.
    eg. user1 , shields = 600 , XP = 50. So all the users who has shields in the range of 600 - 300, 600 + 300 and who has the closest XP level should be chosen for match making.
    Also if no appropriate user is found then in default fall back should be closest XP level.
    Please let me know if this can be achived in current system, if not then could you please provide getRoomList sample as it's not avaiable in the Load balancing sample given.

  • Kaiserludi
    Kaiserludi admin
    edited June 2016
    Options
    Hi @Harish_Kagale.

    With the default lobby filters must match properties exactly. Filtering for ranges that a room property value may have, like shield 300-900 is possible by joining a lobby of type "SQL Lobby": http://doc.photonengine.com/en-us/onpremise/current/applications/loadbalancing/matchmaking-and-lobby
    When following this road you would simply set the allowed maximum and minimum shield level of players in a certain room as room property and then filter for rooms with a max shield level below 900 and a min level above 300.

    For the closest XP you could first filter for a room with maximum XP 51 and minimum 49 and when you don't get a result in a certain time then set the filters to 45 and 55, then 40 and 60, 20 and 80, and so on until you get a matching room.


    Please note that with SQL lobbies there won't be room lists. Those are only available in lobbys of the default lobby type.

    About getRoomList():
    I am not sure what you want to know here. It is really straight forward to use: Just call that function when inside the lobby, iterate over the returned JVector of Room pointers and access the custom properties of each room as return value of Room::getCustomProperties() and use the values of those properties in whatever way you want to determine which room would be the best for the local client to join.
  • Harish_Kagale
    Options
    HI Kaiserludi
    Just wanted to know about getRoomList, does this method provides me the list of all the rooms that are hosted currently (both open and filled ) or just open rooms that needs to be filled.

    i mean open room means room with usercount less than room limit
    Thanks


  • Kaiserludi
    Options
    Hi @Harish_Kagale.

    The room list contains all visible rooms, including rooms which are completely filled and also including rooms that have been explicitly closed by setIsOpen(false). If you want the currently joined room to not show up in the lobby anymore at a certain point (when it is filled or when the match in that room has already started), then you can use setIsVisible(false) to make it invisible. Don't forget to make it visible again if you want it to show up again later.

    IsOpen and IsVisible are completely independent from each other. The former determines if a room can be entered, while the latter determines, if it shows up in the lobby and if it is considered for random matchmaking. A room might be open and invisible to only make it joinable by players that know its ID (for private games that can only be joined by explicitly invited players) or closed and visible (so that it is possible to show running games, that are not joinable anymore, in the lobby).
  • Harish_Kagale
    Options
    Hi Kaiserludi
    I want to get the updated room list frequently after the connection to photon ,
    please guide me to so
  • Kaiserludi
    Options
    Hi @Harish_Kagale.

    Just implement Listener::onRoomListUpdate(), so that you get informed whenever the room list gets updated. When that function gets called, just call Client::getRoomList() again to access the room list on which that update has already been applied by then.
  • Harish_Kagale
    edited August 2016
    Options
    Hi Kaiserludi
    The callback onRoomListUpdate(), is not getting called when the client is actuly joined in one of room ?
    Is that the correct behavior ?
    that the room list is updated only if the client has not joined any Room ?
  • Kaiserludi
    Options
    Hi @Harish_Kagale.

    Yes, that is the correct behavior.

    Room lists are a feature of the lobby (to be specific: a feature of lobbies with lobby type 'Default' - SQL lobbies don't have this feature).

    When a client enters a room, it disconnect from the master server, where the lobby is hosted, and reconnects to the game server ob which the game room is hosted. A client instance can only be connected to one server instance at once, so it can either be connected to a master or to a game server, but not to both at once.

    It is possible to connect to create multiple Client instances and let one of them always stay in the lobby to receive room list updates all the time, while the other one as main instance enters the actual game rooms.
    However that means having two concurrent connections (CCU) per user. As on Photon Cloud the pricing is per CCU, you would this way pay twice as much, so this approach may only be a suitable option for you if you are either using a self hosted Photon Server or if you don't mind the increased CCU usage.

    An alternative approach for Photon Cloud would be to self-host an additional client that is always in the lobby and that's sole purpose is to receive the room list updates. That client could then forward the up to date room list to all real clients either through an external service like a HTTP server to which all clients would connect, or through Photon Chat.