I've been building a UDP server and have hit a bit of a stumbling point. Since UDP is not a persisted connection, there really isn't a way for me to track if the Player has left the current session/closed the game etc.
What I was planning on doing was having the server/client perform some kind of handshake when the client first attempts to join a game session. The server would store the server-side Player object and it's associated EndPoint(s) in a collection. This way, when Player A does something that affects Player B, I can update the two player objects on the server-side and send both players updated info.
What happens if Player A closes the game? I need to clean up my collection of Player/Endpoint(s). I'm not sure how that is typically handled. Should I have a timer that runs every minute or two, pinging clients and removing them if no ping comes back? Since It's UDP, I can't assume that "no new datagrams" really means the player isn't playing. It's possible that they've just not needed to send any data for a while (maybe it's paused or something idk). I have a low-overhead async timer API that runs on background threads that I could use, but it feels like a lot of overhead to ping every connected client every couple of minutes.