1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 17:13:06 +08:00

Fix test compilation error

This commit is contained in:
smoogipoo 2021-05-20 17:20:30 +09:00
parent df80531a0a
commit 750a5c3ea9

View File

@ -1,11 +1,15 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable enable
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Online; using osu.Game.Online.API;
using osu.Game.Online.Spectator; using osu.Game.Online.Spectator;
using osu.Game.Replays.Legacy; using osu.Game.Replays.Legacy;
using osu.Game.Scoring; using osu.Game.Scoring;
@ -14,16 +18,16 @@ namespace osu.Game.Tests.Visual.Spectator
{ {
public class TestSpectatorClient : SpectatorClient public class TestSpectatorClient : SpectatorClient
{ {
public override IBindable<bool> IsConnected { get; } = new Bindable<bool>(true);
public new BindableList<int> PlayingUsers => (BindableList<int>)base.PlayingUsers; public new BindableList<int> PlayingUsers => (BindableList<int>)base.PlayingUsers;
private readonly ConcurrentDictionary<int, byte> watchingUsers = new ConcurrentDictionary<int, byte>(); private readonly ConcurrentDictionary<int, byte> watchingUsers = new ConcurrentDictionary<int, byte>();
private readonly Dictionary<int, int> userBeatmapDictionary = new Dictionary<int, int>(); private readonly Dictionary<int, int> userBeatmapDictionary = new Dictionary<int, int>();
private readonly Dictionary<int, bool> userSentStateDictionary = new Dictionary<int, bool>(); private readonly Dictionary<int, bool> userSentStateDictionary = new Dictionary<int, bool>();
public TestSpectatorClient() [Resolved]
: base(new DevelopmentEndpointConfiguration()) private IAPIProvider api { get; set; } = null!;
{
}
public void StartPlay(int userId, int beatmapId) public void StartPlay(int userId, int beatmapId)
{ {
@ -61,19 +65,25 @@ namespace osu.Game.Tests.Visual.Spectator
sendState(userId, userBeatmapDictionary[userId]); sendState(userId, userBeatmapDictionary[userId]);
} }
public override void WatchUser(int userId) protected override Task BeginPlayingInternal(SpectatorState state) => ((ISpectatorClient)this).UserBeganPlaying(api.LocalUser.Value.Id, state);
{
base.WatchUser(userId);
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. // When newly watching a user, the server sends the playing state immediately.
if (watchingUsers.TryAdd(userId, 0) && PlayingUsers.Contains(userId)) if (watchingUsers.TryAdd(userId, 0) && PlayingUsers.Contains(userId))
sendState(userId, userBeatmapDictionary[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 _); watchingUsers.TryRemove(userId, out _);
return Task.CompletedTask;
} }
private void sendState(int userId, int beatmapId) private void sendState(int userId, int beatmapId)