Is there a way to get the length of time a player was connected?

Options
This would be pretty cool for analytics -- is this possible to see the length of session? I'm looking around, but I may be blind. It's not a big deal, but cool if integrated ;D

Comments

  • Hi @xblade724,

    I guess there is nothing built-in that you can use directly but there are other possibilities to achieve what you want.

    You firstly have to define what you mean by 'connected': Connected to Photon, joined a lobby or even joined a room? Each of this possibilities have their own callback being called on the given event. When one of these gets called you can either work with PhotonNetwork.ServerTimestamp, Unity's Time.time or Time.realtimeSinceStartup or even the System's time. When having one of this values stored you can calculate the difference between this value and the 'current' time to get the duration of the session. To achieve this once the player disconnected you have again additional callbacks for leaving a room (or a lobby) or disconnecting from Photon.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @xblade724,

    I can add a couple of suggestions:

    If you want to measure whole player session:
    - use a proper Analytics SDK (fabric's answers, Google Analytics, GameAnalytics, etc.), log/add event when player connects or disconnects from Photon. You could use your own HTTP based solution or even make use of WebRPCs.

    If you want to measure room sessions:
    - WebHooks (especially GameJoin and GameLeave)
    - Add a join timestamp as a player property
  • xblade724
    Options
    cheers, guys -- tons to work with.