From 750a5c3ea96530fae27195fd5afb0fe89ff4dd0c Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 20 May 2021 17:20:30 +0900 Subject: [PATCH] Fix test compilation error --- .../Visual/Spectator/TestSpectatorClient.cs | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/osu.Game/Tests/Visual/Spectator/TestSpectatorClient.cs b/osu.Game/Tests/Visual/Spectator/TestSpectatorClient.cs index 985e293981..6bd9f1a920 100644 --- a/osu.Game/Tests/Visual/Spectator/TestSpectatorClient.cs +++ b/osu.Game/Tests/Visual/Spectator/TestSpectatorClient.cs @@ -1,11 +1,15 @@ // Copyright (c) ppy Pty Ltd . 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 IsConnected { get; } = new Bindable(true); + public new BindableList PlayingUsers => (BindableList)base.PlayingUsers; private readonly ConcurrentDictionary watchingUsers = new ConcurrentDictionary(); private readonly Dictionary userBeatmapDictionary = new Dictionary(); private readonly Dictionary userSentStateDictionary = new Dictionary(); - 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)