Need an event callback for inactive players?

I need an event be fired when a player become inactive and when he\she rejoin to the room. IPunCallbacks needs a callback like OnPhotonPlayerInactiveChanged!

Answers

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @ahoogol,

    Thank you for your suggestion.
    @jeanfabre already had a similar idea.

    I think currently you can only get join and leave events, I have to check if it makes sense to check if a player is inactive or not in the leave event to make a distinction between new players or rejoining ones.
  • Hi,

    yes, it's on our Todo, it will get done.

    Bye,

    Jean
  • Is this implemented?
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited June 2019
    Hi @gulati,

    Thank you for choosing Photon!

    Yes, this was added to PUN1 but gone in PUN2.

    Which version are you using?

    In PUN1, there is OnPhotonPlayerActivityChanged(PhotonPlayer otherPlayer).
    In PUN2, use IInRoomCallbacks.OnPlayerEnteredRoom(Player otherPlayer) and IInRoomCallbacks.OnPlayerLeftRoom(Player otherPlayer).

    Always check otherPlayer.IsInactive.

    The only info missing in PUN2 is player rejoin: in OnPlayerLeftRoom the player is never inactive.
  • Hi John,
    Actually I was referring to the plugin. Is there an event for plugin that is raised when a player gets deactivated, or is there a way to detect a player getting deactivated so that I can notify the opponent(s).

    Thanks
  • @gulati : Now I'm confused.
    Above your post, JohnTube named the callbacks in PUN/Realtime in the Unity C# client side.
    You mean the server plugins?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @gulati,

    If you are talking about server-side game server plugins, then to tell if a player got deactivated use ILeaveGameCallInfo.IsInactive and ILeaveGameCallInfo.Reason in OnLeave(ILeaveGameCallInfo info).

    You should know that the server automatically sends an event to all joined actors when an actor becomes inactive or when removed from actors list after Player TTL expiration.
  • Hi @Tobias,
    Sorry for the confusion, but I was referring to server plugin callbacks. I could not find a callback for a player becoming inactive (disconnected).

  • Hi @JohnTube,
    Another issue related to player disconnection.
    I have set playerttl to 60 seconds, from what I can understand is that if the user remains disconnected for longer than playerttl then they will be removed from the room. However, I am not getting a Leave callback on webhook plugin incase one of the player gets disconnected (Wifi disabled, goes to background etc.) for more than 60 seconds.
    I do get a timeoutdisconnected event on the plugin, after 6-7 seconds of a player getting disconnected, but post that I do not get a Leave callback even if the player remains disconnected for longer duration than 60 seconds (I have waited for more than 5 minutes, but still no Leave callback.

    Thanks
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @gulati,

    First I want to make sure that by 60 seconds you mean 60000 milliseconds.
    PlayerTTL is in milliseconds.
    Even if it's 60 seconds it should still be triggered anyway.

    If you are using plugins with self-hosted Photon Server version v4.0.29.11263 and also testing webhooks using that same version, there could be a bug preventing the callback to be triggered properly in this situation.
    This is already fixed in Photon Cloud I think, you could try webhooks on Photon Cloud to make sure.

    I could not find this fix in our code base's commits history.
    Maybe @chvetsov knows better.
  • hi, @gulati

    OnLeave call should be there. but there is one difference between sdk you are using and current cloud version. In you case callInfo will contain null in Request property.

    I assume that this may lead to NullRef somewhere. Please check server logs (deploy/log) maybe you may find something there

    best,
    ilya
  • Hi @chvetsov ,
    I am getting a NullReference Exception at line number 304 WebHooksPlugin.cs. Is it possible to get a patch for the same that fixes this exception.
    Thanks
    Gulati
  • It will be difficult to provide fix right away

    You may fix it your self. I think it fails in line 318 because we use info.Request.WebFlags when Request is null. You may fix this and rebuild WebHooks plugins

    -best,
    ilya
  • Are you suggesting that I remove the line number 318, rebuild the plugin and check.

    Thanks
    Gulati