Lobby Info update on non-host clients

Hey its me again,
sorry to bother again. I hope we will find a quick solution for this problem:
When 3 clients joined the lobby (one is the host) and one client leaves the lobby, then the player list gets only updated in the Lobby UI of the Host. The player list of the other Clients UI still has the disconnected Player on it. If the third player reconnects then the lobby menu gets properly updated on all clients. So I think the “lobbyInformationUpdateProcess” works fine when players connect but does not when players disconnect.
Is it possible, that this is not only my Problem but a Problem in the Code of this course? I was wandering because the event ClientOnInfoUpdated gets called in OnStopClient. As far as I understand OnStopClient only gets called on the Host and on the Client that just left the Server. To me this is the reason why the other (Non host-) Clients dont get a proper Info update in their lobby when a Client leaves.
Is that correct? If so what is the solution? If not what am I missing?

Kind regards and thanks for the help and info
Frederick

Hey Freddie, you may be correct here, passing it along so an official fix can be added.

Thinking about this, we need a way for the server to tell the clients that the name has been updated. So when the info update is triggered, the server needs to call an RPC on the clients.

I tested this out and it worked. I created a new Server method and subscribed it to the ClientOnInfoUpdated:

[Server]
public void TriggerLobbyMenuUpdate()
{
        RPCLobbyMenuUpdateOnClient();
}

//In OnStartServer() subscribe
RTSPlayer.ClientOnInfoUpdated += TriggerLobbyMenuUpdate;

This new method calls an RPC that runs the updates on the client. I had to make the lobby method public for this to work.

[ClientRpc]
public void RPCLobbyMenuUpdateOnClient()
{
    FindObjectOfType<LobbyMenu>().ClientHandleInfoUpdated();
}
2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms