Is it safe to use important actions in condition `IsMasterClient`?

Options
I need to ensure that action will be executed despite master player left the room
I have some long/async operation inside `if (player.IsMasterClient) { ... }` that does some properties mutations to continue the game and if master client leaves while action still not finished my game will freeze.

I've done a simple messaging based on events and static `Action` field which is assigned by each user and some listeners to track that master client left and then perform re-invoke of that action if current player becomes a master.
Is it good way? Am I reinventing the wheel?

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited April 2019
    Options
    Hi @Chernikov,

    Is it good way? Am I reinventing the wheel?
    You are not re inventing the wheel. You need to do some custom logic on your side to handle master client switch or "host migration". Whether your approach is good or not, this depends on your game and only you and your players' experience can judge this.

    Read more about "Master Client and Host Migration"