Duplicate OnLeave callbacks while playerTtl > 0
Options
Djebedia
✭
Hi!
I have a room with playerTtl equal to 20000 and a couple of players within it. If any of those players has connection problems then OnLeave callback is called twice: the first time is not exactly after the player has left the room but a bit later and the second time is (or seemed like) the playerTtl period after the first one.
So I wonder if this is the expected behaviour? If it is, why is it so and is there a way to detect if this was the first callback for the exact player or the second?
I have a room with playerTtl equal to 20000 and a couple of players within it. If any of those players has connection problems then OnLeave callback is called twice: the first time is not exactly after the player has left the room but a bit later and the second time is (or seemed like) the playerTtl period after the first one.
So I wonder if this is the expected behaviour? If it is, why is it so and is there a way to detect if this was the first callback for the exact player or the second?
0
Comments
-
Hi @Djebedia,
Thank you for choosing Photon!
I assume this is about PUN2 and the OnLeave callback is actually OnPlayerLeftRoom.
Yes, this is the expected behaviour.IInRoomCallbacks.OnPlayerLeftRoom(Player otherPlayer)
is called when the player leaves the room (sometimes after disconnection timeout) or when the PlayerTTL expires.
You can know which player using the argument passed to the callback.0 -
Thanks for replying!
And I'm sorry for my English! )
Well, I guess it's just PUN classic v1.90 - not PUN2, and I'm still talking about PluginBase.OnLeave(ILeaveGameCallInfo info). But anyway if it's called twice: on disconnect and when PlayerTTL expires - that's fine, but still I have a question:JohnTube said:I assume this is about PUN2 and the OnLeave callback is actually OnPlayerLeftRoom.
Yes, this is the expected behaviour.IInRoomCallbacks.OnPlayerLeftRoom(Player otherPlayer)
is called when the player leaves the room (sometimes after disconnection timeout) or when the PlayerTTL expires.
I wasn't wondering about which player it is, I was trying to figure out if current player's disconnect is already processed, so I don't have to do it again on the second time the OnLeave event is called - is there such a way?JohnTube said:You can know which player using the argument passed to the callback.
0 -
Well, I think I've figured it out: the IsInactive property of ILeaveGameCallInfo argument is set to true until the player is finally kicked from the server. )0
-
the IsInactive property of ILeaveGameCallInfo argument is set to true until the player is finally kicked from the serveryes, that's it.
You didn't mention anything about plugins so I didn't consider it at all.
We usually redirect or expect the discussions about Plugins to be in the Photon Server category.0 -
Oh, I'm sorry - I'm new to this forum and Photon itself )0
-
And back to those OnLeave events: when should it be called the first time? I mean, if client has some connection problems it takes some time before this event fires the first time - is there any way to shorten it?0
-
hi, @Djebedia
If you are going to use self-hosted solution, then you may update server settings so, that it will react faster. I mean you may reduce the timeout interval. But do not make it too small. Customers might be disconnected wrongly
Start here:
https://doc.photonengine.com/en-us/server/current/operations/server-config
Look for 'Timeout settings'
More details here: https://doc.photonengine.com/en-us/server/v4/operations/server-config-settings
best,
ilya0 -
Yay! setting MinimumTimeout and MaximumTimeout values solved my problems! Thanks again!0
-
In my case, I get 2 calls but in both calls
otherPlayer.IsInactive
is true. Not sure how to handle this case.
The only difference isPhotonNetwork.PlayerList.Length
updates properly in the second call.0 -
Hi @Sathyaraj,
Thank you for choosing Photon!
What PUN version is this?
What PlayerTTL do you use?
How do you leave rooms?0 -
Hi, I set TTL to 2000ms. It behaves same when players forcefully closes the app or leaves the room with LeaveRoom() api
Using PUN 2.3. Lib ver 4.1.2.3
If ttl is set to 0 it works fine0