Correct flow of joining random room

Hello everyone! At first, a little disclaimer. I am planning to use PUN (with photon cloud) in my project as a most reliable and easy to use multiplayer backend. I am moving form combination of Google Play multiplayer and Unity networking, which was proven unusable in serious projects. I will be asking a series of questions for which I didn't find the answers in docs or somwhere else (forum, stackoverflow, unity answers). Don't get me wrong, I will be glad if I'm mistaking, and the answers are obvious or easy to find. Anyway, please point me in right direction and please don't leave any of this questions unanswered.

My third question is about safe and correct way to join a random room. My goal is to implement "Quick game" functionality, when player presses one button, all connection-related stuff happens behind the scenes, no additional ui is shown, player either successfuly connects, or sees an error message. It was rather easy to implement with Google Play, but it seems to be harder with Photon. For now I implemented a way shown in Marco Polo tutorial which leads to this behaviour: when a player can't join a random room a new room is created; when two players initiate quick game at the moment when all rooms are filled or there are no rooms at all, they both create a room and continue to wait for other players. Is there a way to change this behaviour and connect such players together? I think this sometimes could be a serious issue, especially on early stages with not so many active users, especially if cloud regions are completely separated.
Another question is about detemining correct count of players to consider the random room filled. In my game room could be from 2 to 8 players. Any number in this range is allowed. When the game is started no one is allowed to join (separate question, how to correctly achieve that?). How do I implement a random room with more than two players? Is this completely on me? Should I implement some kind of timer, counting from the last player joined (e.g. if no one joins for 10 seconds - start the game)? Is there an example (approved by exitgames) which shows a correct way to handle all of the unexpected events (e.g. master client leaving)? Any advice appreciated.

Comments

  • Hi diablo23q.

    Yes, this issue that you have described with two players not finding each other, because the try joining and creating a room at the same moment, is a known limitation.
    You can set the max players of a room and also if it is open and if it is visible, when creating the room. All of this can also be changed through the rooms properties later on. A room will not be found anymore by random matchmaking, if it either has reached it's max players capacity or if it is closed or if it is invisible. If it is only invisible, but neither open nor at its max players limit, then players can still join that room, if they already know its room id, but it won't be shown in the list of open rooms or be used for random matchmaking.
  • Thanks! So I'll just close the room via properties when the game is started. As for the first question, I'll try to improve my logic based on some timers, maybe random (e.g. no one joined in my room for 15 +- 10 sec -> try to re-join random room. I guess with some probability players will connect, in the worst case i'll show some message).