Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Third Party Photon Network Room Basic Question: how to close?

Discussion in 'Multiplayer' started by jpthek9, Nov 10, 2014.

  1. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    How do I close a room after it's created so nobody else can join? I want to do this when I load the game for all the players in the room
     
  2. aanimation

    aanimation

    Joined:
    Oct 23, 2012
    Posts:
    49
    im using photon too,
    own experiences, while no one in room, then the room be invisible/anyone cant join/destroy.

    if you want to close room as private room
    Code (CSharp):
    1. if (GUILayout.Button("Create Room", GUILayout.Width(100), GUILayout.Height(80)))
    2.         {
    3.             RoomOptions roomOptions = new RoomOptions()
    4.             {
    5.                 isVisible = true,
    6.                 isOpen = false,
    7.                 maxPlayers = 5
    8.             };
    9.             PhotonNetwork.CreateRoom(roomName, roomOptions, TypedLobby.Default);
    10.         }
    i hope it can help u..
     
  3. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,022
    If you close a room, it's best practice to also set isVisible to false. This way, it's not listed in the lobby (if you use that).
    When you're in a room, use PhotonNetwork.room.isOpen to close or open the room.
     
    WaTcH_DOGZ likes this.
  4. thanhvinh1

    thanhvinh1

    Joined:
    Nov 6, 2016
    Posts:
    1
    If the room isn't opened, can disconnected players reconnect to that room? I mean use method JoinRoom(roomId) or something like that.
     
  5. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,022
    Join() won't work but as long as a player is still in the room, that client can use RejoinRoom() or ReconnectAndRejoin().
    Important: Clients drop out of rooms, if their connection is lost, unless you set a PlayerTTL value, when you create the room (it's a per room setting in the RoomOptions, when you create it). The PlayerTTL keeps players in the room as inactive, when the connection drops.
    Also important: Players can rejoin rooms based on their userID. This makes sure that only the exact same user is capable to rejoin. So you need to store the userID the server gave you or come up with your own. Set it via the AuthValues.
     
    AthanS likes this.