Logistics of a server browser

Note: I don’t know if this should go in Code Review or Scripting Support since I’m not actually showing code but because it works I’m putting it here.

I’ve got a server browser system I’m making, and while it works I think the system is a bit bad logically.
Basically, every 15 seconds the server clears its list of other servers and sends a request using MessagingService to get the info of other servers. When the client manually refreshes servers, it uses the list from the server.
I think the issue is obvious: If the client refreshes in the middle of the server refreshing, it doesn’t get all of the servers. I was thinking of implementing a delay where the server has to go a couple seconds without receiving another message before the client refresh can finish, but I feel like there’s a better way to do this.

Tricky question. Here’s one way:

  • Each server has a local server list; each server is stored with a timestamp.
  • Every 15 seconds, each server broadcasts a message to other servers containing itself.
  • When a message is received, it is added to the server list, or if it is already in the list, it just resets the timestamp.
  • The server broadcasts a message when it is about to close. (Optional.)
  • Any server which has not been updated for over 30 seconds is removed from the list.

This way, the server list is never cleared.