How to ReconnectAndRejoin ?

Options
Hi, I quite confused on how to reconnect when we got OnConnectionFail ? because when I got disconnected, I call ReconnectAndRejoin, but my player avatar (prefab) is gone from Editor since I got disconnected.

Answers

  • Hi @metallizard,

    you can reconnect and rejoin a room, if you set certain options on room creation. When creating a room, you can set RoomOptions. You can use these options, to set PlayerTtl (describes how long a client becomes inactive before he gets removed from the room on the server) and EmptyRoomTtl (describes how long an empty room is kept alive on the server). Both values are described in ms. For example:
    RoomOptions options = new RoomOptions();
    options.PlayerTtl = 30000; // 30 seconds
    options.EmptyRoomTtl = 60000; // 60 seconds
    
    PhotonNetwork.JoinOrCreateRoom("Room Name", options, null);