Search Unity

Problem Creating a Room

Discussion in 'Multiplayer' started by Livindaki, Jul 10, 2019.

  1. Livindaki

    Livindaki

    Joined:
    Jun 13, 2017
    Posts:
    49
    hi
    i am using PUN2
    when i create a room its automaticly joined the room
    how can i prevent that and just wait for OnCreatedRoom to use for creating another room ...
    with this problem i used PhotonNetwork.LeaveRoom() to go to next step for creating the next room . but i am lossing all created room .and i dont think that this method is right !!!!! .
    Any help Please .
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    A user can only be in one room. If a room becomes empty, it's cleaned up.
    There is no built-in way to just create rooms that wait for players.

    Use the PUN matchmaking doc as guide.
     
  3. Livindaki

    Livindaki

    Joined:
    Jun 13, 2017
    Posts:
    49
    but in a PUN Documents using RoomOptions .EmptyRoomTtl for keeping Empty rooms to rejoin .. have you any idea about how using that and keeping room all the time in memory and not for a specif ms .. i used it like :
    myRoomOptions .EmptyRoomTtl =6000;
    it worked for 6 Sec .
    but i need it to stay always .
    and idea please ?
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    Photon does not allow you to keep rooms open just to wait for someone. This would make our load balancing less effective and has no purpose (the room is empty).
    If you wanted to show some room, even if there is none, do it on the client. No server needed to show a few empty entries in a list.

    In best case, look up which rooms there are and if there are none, create a room on the fly. See the matchmaking guide.

    If you need the other system, you can do matchmaking on another server, external to Photon. Photon has WebHooks to keep a http-based server up to date when rooms get created and destroyed, so your server has that insight on demand.