mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 14:52:57 +08:00
Fix test compilation error
This commit is contained in:
parent
df80531a0a
commit
750a5c3ea9
@ -1,11 +1,15 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Online;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Spectator;
|
||||
using osu.Game.Replays.Legacy;
|
||||
using osu.Game.Scoring;
|
||||
@ -14,16 +18,16 @@ namespace osu.Game.Tests.Visual.Spectator
|
||||
{
|
||||
public class TestSpectatorClient : SpectatorClient
|
||||
{
|
||||
public override IBindable<bool> IsConnected { get; } = new Bindable<bool>(true);
|
||||
|
||||
public new BindableList<int> PlayingUsers => (BindableList<int>)base.PlayingUsers;
|
||||
private readonly ConcurrentDictionary<int, byte> watchingUsers = new ConcurrentDictionary<int, byte>();
|
||||
|
||||
private readonly Dictionary<int, int> userBeatmapDictionary = new Dictionary<int, int>();
|
||||
private readonly Dictionary<int, bool> userSentStateDictionary = new Dictionary<int, bool>();
|
||||
|
||||
public TestSpectatorClient()
|
||||
: base(new DevelopmentEndpointConfiguration())
|
||||
{
|
||||
}
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; } = null!;
|
||||
|
||||
public void StartPlay(int userId, int beatmapId)
|
||||
{
|
||||
@ -61,19 +65,25 @@ namespace osu.Game.Tests.Visual.Spectator
|
||||
sendState(userId, userBeatmapDictionary[userId]);
|
||||
}
|
||||
|
||||
public override void WatchUser(int userId)
|
||||
{
|
||||
base.WatchUser(userId);
|
||||
protected override Task BeginPlayingInternal(SpectatorState state) => ((ISpectatorClient)this).UserBeganPlaying(api.LocalUser.Value.Id, state);
|
||||
|
||||
protected override Task SendFramesInternal(FrameDataBundle data) => ((ISpectatorClient)this).UserSentFrames(api.LocalUser.Value.Id, data);
|
||||
|
||||
protected override Task EndPlayingInternal(SpectatorState state) => ((ISpectatorClient)this).UserFinishedPlaying(api.LocalUser.Value.Id, state);
|
||||
|
||||
protected override Task WatchUserInternal(int userId)
|
||||
{
|
||||
// When newly watching a user, the server sends the playing state immediately.
|
||||
if (watchingUsers.TryAdd(userId, 0) && PlayingUsers.Contains(userId))
|
||||
sendState(userId, userBeatmapDictionary[userId]);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override void StopWatchingUser(int userId)
|
||||
protected override Task StopWatchingUserInternal(int userId)
|
||||
{
|
||||
base.StopWatchingUser(userId);
|
||||
watchingUsers.TryRemove(userId, out _);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void sendState(int userId, int beatmapId)
|
||||
|
Loading…
Reference in New Issue
Block a user