Best Practice in regards to MasterClient

Options
Hi,

So, master client is assigned to the first person who enters the world. And then when that master client logs out, a new one is randomly selected. I've read that when sending RPC's to the master client, it can be dangerous because if the master client logs out or something at the same time, the RPC will not send, and it will be lost.


Is it good practice to have a blank master client running on my dedicated server that isn't a playable characters and it's just a client that stays running forever so that there is always a dedicated master client? Is this a good idea? Are there downfalls to this? I see a positive in that when sending master client RPC calls, you're guaranteed to receive them because I player isn't going to be Masterclient.

Thanks in advance!

Comments

  • Tobias
    Options
    The new Master Client is not assigned randomly, but in order of joining the room. The oldest, active player becomes Master Client, if the current one left.

    When sending messages to the Master Client, the problem is that we can't always notice when it drops out. If the device loses connection, some messages will be sent in that direction but never arrive. Only after a timeout of several seconds, we detect a disconnect (by timeout) and then assign a new Master Client.

    Despite this issue, it's super uncommon to have dedicated clients to be master. It's usually better to store some game state in the Custom Room Properties and then live with a little gap when another Master Client has to take over.
    In doubt, you could send updates to all players, even if they are only relevant for the Master Client. If another player takes over the duty, then it already has the state and it becomes the client which is reacting to the messages for the Master Client.