PhotonNetwork.JoinOrCreateRoom() for random rooms?

Hello,

Is there a way to atomically join-or-create a random room? I thought it would be the case when I call PhotonNetwork.JoinOrCreateRoom() with a null room name, but that does not work. If I do specify a name then I can only create up to 1 room with the required criteria.

The use-case I am trying to implement is - users can join a Photon room to play a specific level. For that, I am setting a custom property 'Level'= and use that property for the lobby.
I'd like the 1st player to attempt to join-or-create that room to succeed and create a room with a random name, and other players to join that player in that room. When the room is full and another player tries to join-or-create, another room with a random name is created (but with the same 'Level'= property.

Is this possible?

As a workaround I am currently performing two separate calls - JoinRandomRoom() followed by CreateRoom() if the former has failed. This, however is not ideal, because players who attempt to join a room at roughly the same time end up in separate room instances.

Thanks,
Sylwester

Best Answer

Answers

  • OK, thanks for the clarifying it @JohnTube .