mirror of
https://github.com/ppy/osu
synced 2025-01-19 12:30:50 +00:00
Simplify TestSpectatorClient implementation
This commit is contained in:
parent
07fde1db6d
commit
750f90e728
@ -6,7 +6,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -40,11 +39,7 @@ namespace osu.Game.Tests.Visual.Spectator
|
|||||||
|
|
||||||
public TestSpectatorClient()
|
public TestSpectatorClient()
|
||||||
{
|
{
|
||||||
OnNewFrames += (i, bundle) =>
|
OnNewFrames += (i, bundle) => lastReceivedUserFrames[i] = bundle.Frames[^1];
|
||||||
{
|
|
||||||
if (PlayingUsers.Contains(i))
|
|
||||||
lastReceivedUserFrames[i] = bundle.Frames[^1];
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -65,7 +60,7 @@ namespace osu.Game.Tests.Visual.Spectator
|
|||||||
/// <param name="userId">The user to end play for.</param>
|
/// <param name="userId">The user to end play for.</param>
|
||||||
public void EndPlay(int userId)
|
public void EndPlay(int userId)
|
||||||
{
|
{
|
||||||
if (!PlayingUsers.Contains(userId))
|
if (!userBeatmapDictionary.ContainsKey(userId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
((ISpectatorClient)this).UserFinishedPlaying(userId, new SpectatorState
|
((ISpectatorClient)this).UserFinishedPlaying(userId, new SpectatorState
|
||||||
@ -73,6 +68,8 @@ namespace osu.Game.Tests.Visual.Spectator
|
|||||||
BeatmapID = userBeatmapDictionary[userId],
|
BeatmapID = userBeatmapDictionary[userId],
|
||||||
RulesetID = 0,
|
RulesetID = 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
userBeatmapDictionary.Remove(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public new void Schedule(Action action) => base.Schedule(action);
|
public new void Schedule(Action action) => base.Schedule(action);
|
||||||
@ -131,7 +128,7 @@ namespace osu.Game.Tests.Visual.Spectator
|
|||||||
protected override Task WatchUserInternal(int userId)
|
protected override Task WatchUserInternal(int userId)
|
||||||
{
|
{
|
||||||
// When newly watching a user, the server sends the playing state immediately.
|
// When newly watching a user, the server sends the playing state immediately.
|
||||||
if (PlayingUsers.Contains(userId))
|
if (userBeatmapDictionary.ContainsKey(userId))
|
||||||
sendPlayingState(userId);
|
sendPlayingState(userId);
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
Loading…
Reference in New Issue
Block a user