The times can be changed based off of requirements
- Each client should assume it is not a master at the start
- A client that is a master should broadcast a discovery message every 5 seconds.
- A client that is a master should stop being a master if it sees another client broadcasting a discovery message.
- A client that has not seen a discovery message for 10 to 25 seconds (random for each client) should make itself a master and broadcast a discovery message.
- The discovery message should contain a unique nonce.
- Each client should broadcast a response containing a hash of its own ID, a private value (unique per group of people that want to sync) and the nonce.
- Clients should check the hash to match what they expect, by calculating it with the nonce, the client’s ID and what it assumes is the correct private value.