Game session tracking
Track game sessions and log them to the DB. The data could be used to determine how active a given player is and combined for statistics. There should be an option to enable/disable the feature and configuration for the maximum amount of sessions persisted per user.
game_sessions
table structure
id
steamid
-
server
- the ID of the server start_timestamp
end_timestamp
-
duration
- session length in seconds
A time_played
column should be added to the users
table and incremented when ending sessions for more efficient future retrieval of the total time played.
Insert a new game session record and store the session ID when a player connects.
- Send an ending time (along with the ID) when the player disconnects.
- End all valid sessions for a given server when it shuts down, changes the map or restarts.
- Invalidate all active sessions when starting up a server (to recover from crashes etc.)