diff --git a/osu.Game/Online/Spectator/SpectatorStreamingClient.cs b/osu.Game/Online/Spectator/SpectatorStreamingClient.cs index 03387cfb9f..10a707a4ce 100644 --- a/osu.Game/Online/Spectator/SpectatorStreamingClient.cs +++ b/osu.Game/Online/Spectator/SpectatorStreamingClient.cs @@ -47,6 +47,8 @@ namespace osu.Game.Online.Spectator private readonly BindableList playingUsers = new BindableList(); + private readonly Dictionary currentUserStates = new Dictionary(); + [CanBeNull] private IBeatmap currentBeatmap; @@ -60,7 +62,6 @@ namespace osu.Game.Online.Spectator private IBindable> currentMods { get; set; } private readonly SpectatorState currentState = new SpectatorState(); - private readonly Dictionary currentUserStates = new Dictionary(); private bool isPlaying; @@ -124,8 +125,11 @@ namespace osu.Game.Online.Spectator } else { - playingUsers.Clear(); - currentUserStates.Clear(); + lock (userLock) + { + playingUsers.Clear(); + currentUserStates.Clear(); + } } }, true); } @@ -133,11 +137,13 @@ namespace osu.Game.Online.Spectator Task ISpectatorClient.UserBeganPlaying(int userId, SpectatorState state) { - if (!playingUsers.Contains(userId)) - playingUsers.Add(userId); - lock (userLock) + { + if (!playingUsers.Contains(userId)) + playingUsers.Add(userId); + currentUserStates[userId] = state; + } OnUserBeganPlaying?.Invoke(userId, state); @@ -146,10 +152,11 @@ namespace osu.Game.Online.Spectator Task ISpectatorClient.UserFinishedPlaying(int userId, SpectatorState state) { - playingUsers.Remove(userId); - lock (userLock) + { + playingUsers.Remove(userId); currentUserStates.Remove(userId); + } OnUserFinishedPlaying?.Invoke(userId, state);