I don't want it to drop the line, I want to keep it online, what should I do?

Options
enter the room, start the game, if not operated for a long time, it will drop the line, I don't want it to drop the line, I want to keep it online, what should I do?

Answers

  • JPGOrdon
    JPGOrdon
    edited November 2020
    Options
    @fei Can you specify what you mean when you write "if not operated for a long time"? There are the following room properties that may be related: playerTTL, time in MS that an inactive player stays connected, and roomTTL, time in MS that the room stays alive. You can define these properties in a RoomOption variable and pass it to whatever function creates your rooms, for example:
    RoomOptions newRoomOptions = new RoomOptions();
    newRoomOptions.isVisible = roomIsVisible;
    newRoomOptions.PlayerTtl = 5000;
    newRoomOptions.EmptyRoomTtl = 10000;
    newRoomOptions.ma
    PhotonNetwork.CreateRoom(onlineRoomName, newRoomOptions, null);
    // OR PhotonNetwork.JoinRandomOrCreate(....)
    

    If your question pertains to how to leave a room without disconnecting from Photon, checkout the documentation on the PhotonNetwork class. You could invoke PhotonNetwork.LeaveRoom() to simply leave the current room without idling. There are also functions to reconnect you to the photon network with PhotonNetwork.Reconnect(), rejoin the last room with PhotonNetwork.RejoinRoom() and to do both with PhotonNetwork.ReconnectAndReJoin().