#ScoreBoard

5 messages · Page 1 of 1 (latest)

sand oasis
#
 [SyncObject]
  public readonly SyncDictionary<NetworkConnection, string> _playerNames = new SyncDictionary<NetworkConnection, string>();  

Accessed like so in a seperate script:

    private void RefreshScoreboard()    //TODO: Clients not 'deteting' other clients leaving.
    {
        _text.text = "";

        foreach (var playerEntry in _playerNameTracker._playerNames)
        {
            NetworkConnection connection = playerEntry.Key;
            string playerName = playerEntry.Value;

            _text.text += playerEntry.Value + "\n";
            Debug.Log("Connection: " + playerEntry.Key + ", Name: " + playerEntry.Value);
        }

Working prefectly except....

On the server, a disconneceted client is removed form the dictionary ✅
On client side, the Debug.Log of a disconnected client shows : Id[-1] and Address [Unset], so they're still in dictionary ❌

How do I ensure this removal of a disconnected client that occurs correctly on the server side also occurs on the client side?

Thanks.

#

So to re-iterate, The dictionary IS synced amongst clients, but its not removing a disconnected client as the server does. Instead, it's merely setting their Key: [Unset] and Value: whatever was set by the client

#

Here we have Reading the dictionary from a clients perspective:
Client/Server: playerEntry.Key/Connection = Id [0] Address [], playerEntry.Value/Name: server
Connected Client: playerEntry.Key/Connection = Id [1] Address [], playerEntry.Value/Name: player 0
Disconnected Client: playerEntry.Key/Connection = Id [-1] Address [Unset], playerEntry.Value/Name: player 1

sand oasis
#

Solved: Created a seperate dictionary and subscribed to callbacks from there. Then I just made sure there were [ObserverRpcs] on my methods. Kinda fluked this one...

manic schooner
#

This seems to be my problem as well. I'm keeping track of players in the lobby who have clicked "ready", in a SyncDictionary. When they are removed from the SyncDictionary, client doesn't seem to be getting the value, only the key that was removed. When the player disconnects after clicking "ready", the SyncDictionary key, NetworkConnection, the client receives is "Id [-1] Address [Unset]".