Callbacks are called after some delay

Options
Hi,

void OnPhotonPlayerConnected(PhotonPlayer newPlayer) and
void OnPhotonPlayerConnected(PhotonPlayer newPlayer) are called after 5-6 seconds delay.
Can this time delay be reduced?

Comments

  • Hi @Yogesh_Dev,

    those calls (I guess the second should be the OnPhotonPlayerDisconnected callback) are usually processed directly after the server sends those notifications to the clients, that are already or still in the room.

    About the delay for OnPhotonPlayerDisconnected: this might be possible if you are setting PlayerTtl to a value > 0. In this case, the player who has left the room becomes inactive for a certain amount of time (PlayerTtl) first and gets disconnected if he does not return.

    However OnPhotonPlayerConnected should be called more or less immediately after a new client has joined the room. Does this happen every time you are running the application?
  • Yogesh_Dev
    Options
    hi @Christian_Simon ,
    Thank you for your reply.
    I want to stop the timer in my game as soon as player disconnect from network. and i have set playerttl = 0 but OnPhotonPlayerDisconnected is called after some delay
  • How did you measure the delay and when do you start measuring? As soon as the clients attempts to join a room or is it another moment?

    When connecting to Photon, do you have a stable connection? You can check this out by taking a look at PhotonNetwork.GetPing(); and at PhotonNetwork.ResentReliableCommands. If you have too many resends this might delay joining the room.

    When OnPhotonPlayerDisconnected is called delayed, is the disconnected player disconnected regularly or is he disconnected due to some networking issues? If the client is disconnected due some kind of networking issue (problems with the router, ISP or similar), this might cause a delayed call of OnPhotonPlayerDisconnected as well.

    If this is all fine, you can add the SupportLogger, which is included in the PUN package, and attach it to an object in the scene. It will regularly log some stats to the console, which would be interesting to know, if the problem persists.