[C#] playerDropped while deferring connection

I made a connection script for my server, where it shows an AdaptiveCard to players who join the server, this AdaptiveCard needs to get updated every 2 seconds, so I created a timer that refreshes it every 2 seconds.

The problem with this timer is that it starts once a player joins, but it will not stop once they click ‘Cancel’ or Alt+F4 because the ‘playerDropped’ event only works for players that are actually loaded in (I tested)

How do I detect if someone disconnects during the deferrals stage, and execute an event if they do?

Thanks!

I fixed this problem! playerDropped doesn’t work indeed. However if you run a loop that checks:

if (player.EndPoint == null) {
  // Code to cancel any timers/loops here
}

Once a player presses Cancel, or disconnects from the server their endpoint disappears so this’ll be a good replacement if the player has not yet loaded in to the server yet.

If anyone has a better method, I’m happy to hear in the comments.