Duplicate OnLeave callbacks while playerTtl > 0

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?

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    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.
  • Thanks for replying!

    And I'm sorry for my English! )
    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.

    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:

    You can know which player using the argument passed to the callback.

    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?


  • 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. )
  • JohnTube
    JohnTube ✭✭✭✭✭
    the IsInactive property of ILeaveGameCallInfo argument is set to true until the player is finally kicked from the server
    yes, 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.
  • Oh, I'm sorry - I'm new to this forum and Photon itself )
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hey @Djebedia,

    no worries! you are doing great as a someone just starting with Photon :)
  • 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?
  • 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,
    ilya
  • Привет, @chvetsov )
    Thanks a lot, I'll investigate it!
  • Yay! setting MinimumTimeout and MaximumTimeout values solved my problems! Thanks again!
  • 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 is PhotonNetwork.PlayerList.Length updates properly in the second call.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Sathyaraj,

    Thank you for choosing Photon!

    What PUN version is this?
    What PlayerTTL do you use?
    How do you leave rooms?
  • Sathyaraj
    Sathyaraj
    edited February 2019
    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 fine