How to Get Room Properties if all I have is the room name?

I want to return a list of rooms my friends are playing in, but in my lobbies the room name is actually a custom room property, so when I get the list back in OnUpdatedFriendList() I only have access to the string of the room name (which in my case is just a GUID).

I need to access the custom room properties of the room, but all I have is the room name, is there any way to lookup the room details if all I have is the room name?

Comments

  • JohnTubeJohnTube mod
    edited September 2017
    I saw that you chose to use a custom room property as a "room name" so you can change it post room creation. why? why do you need such thing?

    If you want to access a room property outside a room you need:

    - create room in default lobby type.
    - set custom room property key as lobby property.
    - join same lobby and get list of rooms info.
  • Players in my game join Rooms based on their name, it's a Comedy game where players host rooms and tell jokes, so if I started a room called "Dad Jokes" and then later on during the game the players in the room decides to rather tell "Fat Jokes" the host can rename it so other players in the lobby no what kind of room they will be joining.

    I already have done as you mentioned, but that's for the lobby, I want to get that same info when returning the list of rooms my friends are in. Unfortunately it only returns the string name of the room and not the actual RoomInfo of that room.
  • maybe you should review your friends matchmaking (maybe use Photon Chat or something else to exchange type of jokes) or switch rooms when "the type of joke changes".
  • Or maybe Photon should review their FriendInfo to return the Room instead of just the room name.

    So how am I supposed to get a list of rooms and their info (like number players, type of room etc.) my friends are in if I don't have access to the RoomInfo?
  • xblade724xblade724
    edited October 2017
    > Or maybe Photon should review their FriendInfo to return the Room instead of just the room name.

    Yea, this is where I'm at. I found this thread from Google. I'm a bit shocked there's not a RoomInfo PhotonNetwork.getRoom(string roomName). It's almost like it's purposely annoying so we get Photon chat, although I'd hope it's not like that.

    The proper way is to ONLY do this in the lobby:

    1. Wait for lobby stats to update
    2. After lobby stats updates, wait for the rooms list to update (called onRoomsListUpdate or something). Use intellisense to find the exact name.
    3. Then you have to iterate through all your rooms or use Linq (my fav) to filter/map.
    4. THEN get the room info

    It's unnecessarily difficult compared to everything else with Photon that's so intuitive. What makes things more annoying is that you can ONLY do it when you're not in a room (if you're in a room, I asked before - the response was to get Photon chat).

    Workarounds:

    1 - Learn the Photon API and do your own room list update. I haven't looked into this yet, but theoretically you'd just poll (or on-demand, if your playerbase is low) every so often to get the list and store it on YOUR BaaS (gamesparks, for example). Then you could ask gamesparks (or whatever BaaS you use) for the list of rooms and you'd have it anytime, no matter which part of the game you're in.

    2 - There's some advanced thing I saw where you can use the lower level API to login a 2nd user into the lobby to dig for the stats. However, this will double your MAU since it counts as a user.

    3 - Photon chat. Free until ~100 MAU (is that right?), then +~$45/mo. I'm trying to save money and lean towards the future, so we're skipping this, personally. I still am a bit shocked this isn't natively part of Photon.

    4 - Similar to #1, but instead of polling, at onJoinedRoom() Photon callback, just save your room info to your BaaS' friend info. So when someone invites you to a game (using whatever realtime messaging system you're using), force a friend list refresh (via your BaaS) and you'll have the room info no matter where you are.

    5 - Beg Photon staff to add a RoomInfo getRoom(string room) that would greatly benefit everyone and to keep up with competition? ;) I see it requested throughout the forum.
  • Hi @xblade724,

    Actually there is no need to wait for lobby stats.

    1. Wait for the rooms list to update. In PUN: OnReceivedRoomListUpdate().
    2. Get the room info from the room list.

    About the "workarounds":

    1. This can be done using webhooks + webRPC + external HTTP based web service.
    2. 2 LoadBalancing clients (e.g. PUN + LoadBalancing). Double CCU. Chat would be cheaper.
    3. Why shocked?
    4. Looks like 1 for me.
    5. Not a workaround but a feature request.

    We will discuss internally but I still do not see what is the issue here.
    If you have the room name and you are joined to the same lobby where that room is created you can get the RoomInfo about that room.
  • xblade724xblade724
    edited October 2017
    Because `OnReceivedRoomListUpdate()` only works in the lobby, so it's really troublesome to update friends when you're in a room. For example, if I'm in a room waiting for my friend to hop on, I have to go through an incredible amount of workarounds just to reflect his status as online and not in a room. Or let's say I want to support groups of people -- I'll make a staging room to gather my friends privately, then if I could just grab the list of rooms while in a room, man that'd just be so easy then I can find the best one and join up.

    Instead, I have to temporarily cache everything, leave the old room, wait for callbacks, join the original room, rpc everyone to leave then join the new room ..... just so much beating around the bush when it could be so simplified.

    "Why shocked?"
    I was just a bit shocked since most standard realtime stuff like sending a message to someone or getting a room is extremely difficult in standard situations (forming a group with prevents, for example, explained more below) without paying a separate fee or doing crazy workarounds. That's like if I signed up for Facebook and I'd have to pay extra to message my buddies and not see anything update as long as I'm chatting with someone already. We had to move our entire lobby stats to GameSparks since they include realtime stuff like this without any extra fees with a "sendMessage()" that I expected Photon to originally have -- all these great features, but can't send a message or grab a room? How is the normal flow for dealing with groups of people?

    "but I still do not see what is the issue here."
    Hmm ok - Think League of Legends or something. You invite 2 buddies to a private room. Then you hit the matchmaking button. You are thrown in a queue with other people. Well, you can't group join another room. You can't even get a list of the latest rooms without first leaving the original room. Then you can't alert the original people you were with because you can't message them unless you're in the original room. You'd have to have 1 person LEAVE, matchmake, leave the new room (or break out early), go back into the original room, RPC teammates to leave and join that room together. All types of sloppiness with flags everywhere. All because we can't get rooms in a room and can't message outside a room.
  • JohnTubeJohnTube mod
    edited October 2017
    Hi @xblade724,

    Thank you for your feedback!

    You can't have friends matchmaking with Photon only so usually the issue is solved by using the other service that offers the friends handling feature like for instance facebook, PlayFab (I'm not sure about GameSparks) or your own backend. Those services should provide the feature of sending messages to your friends (to invite them to a room) along with persisting your friends list or managing friendship requests.

    Also the process for friends matchmaking (or "teams matchmaking") we promote and advertise on our documentation website is a bit different from what you have explained and I think a bit simpler:

    if you already know the friends or the team members that will play together, everyone should be on the Master Server, one should be elected to do the matchmaking and others should wait (ofc with a timeout):

    1. the elected "team leader" will do the matchmaking using slot reservation (ExpectedUsers) with the UserIDs of the other members (try JoinRandom or create a new invisible room).
    2. the others should keep checking if the "team leader" is inside a room or not using FindFriends operation, once he's in, they join that room.

    All because we can't get rooms in a room and can't message outside a room.
    These limitations could be due to the architecture of Photon Realtime and the trade-offs that need to be made. Photon is good at scaling your game as long as most traffic is kept inside rooms. Photon Chat has another architecture.
  • @xblade724, you have a valid point, yes. I would like Photon to have a simple solution for your case but so far, we can't help, aside from combining PUN and Chat.

    The "Realtime" server structures, which we use for PUN, are deliberately limiting what they "send around". There are many game servers (running the actual games) and they only have to update the Master Servers about what's going on. To let players have the room lists while being in a room, we would have to send (in worst case) all room lists to all servers and keep everything in sync. This won't scale and or would be expensive.

    Alternatively, we could enable you to run another connection (two CCUs per client). One to play and one that gets the room lists while you do (which would be new). You would use more CCUs that way and .. as far as I know, the "Realtime" CCUs are more expensive than the "Chat" CCUs.

    Also, we don't even want to pass messages while clients use the Master Server, as those have other tasks and players should move on to the Game Servers (which is part of the scaling strategy). Due to this, you can't message "friends" (a.k.a. anyone you ever want to). If you want this, our scaling tech for this looks like Chat. It's just very different to do in large number of players (and we hope you get thousand's of CCUs)...
Sign In or Register to comment.