mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 12:17:46 +08:00
Rename SpectatorStreamingClient -> SpectatorClient
This commit is contained in:
parent
80a714a9c4
commit
6beeb7f7c4
@ -27,8 +27,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
private readonly User streamingUser = new User { Id = MultiplayerTestScene.PLAYER_1_ID, Username = "Test user" };
|
private readonly User streamingUser = new User { Id = MultiplayerTestScene.PLAYER_1_ID, Username = "Test user" };
|
||||||
|
|
||||||
[Cached(typeof(SpectatorStreamingClient))]
|
[Cached(typeof(SpectatorClient))]
|
||||||
private TestSpectatorStreamingClient testSpectatorStreamingClient = new TestSpectatorStreamingClient();
|
private TestSpectatorClient testSpectatorClient = new TestSpectatorClient();
|
||||||
|
|
||||||
[Cached(typeof(UserLookupCache))]
|
[Cached(typeof(UserLookupCache))]
|
||||||
private UserLookupCache lookupCache = new TestUserLookupCache();
|
private UserLookupCache lookupCache = new TestUserLookupCache();
|
||||||
@ -61,8 +61,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
AddStep("add streaming client", () =>
|
AddStep("add streaming client", () =>
|
||||||
{
|
{
|
||||||
Remove(testSpectatorStreamingClient);
|
Remove(testSpectatorClient);
|
||||||
Add(testSpectatorStreamingClient);
|
Add(testSpectatorClient);
|
||||||
});
|
});
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
@ -212,9 +212,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
private void waitForPlayer() => AddUntilStep("wait for player", () => Stack.CurrentScreen is Player);
|
private void waitForPlayer() => AddUntilStep("wait for player", () => Stack.CurrentScreen is Player);
|
||||||
|
|
||||||
private void start(int? beatmapId = null) => AddStep("start play", () => testSpectatorStreamingClient.StartPlay(streamingUser.Id, beatmapId ?? importedBeatmapId));
|
private void start(int? beatmapId = null) => AddStep("start play", () => testSpectatorClient.StartPlay(streamingUser.Id, beatmapId ?? importedBeatmapId));
|
||||||
|
|
||||||
private void finish(int? beatmapId = null) => AddStep("end play", () => testSpectatorStreamingClient.EndPlay(streamingUser.Id, beatmapId ?? importedBeatmapId));
|
private void finish(int? beatmapId = null) => AddStep("end play", () => testSpectatorClient.EndPlay(streamingUser.Id, beatmapId ?? importedBeatmapId));
|
||||||
|
|
||||||
private void checkPaused(bool state) =>
|
private void checkPaused(bool state) =>
|
||||||
AddUntilStep($"game is {(state ? "paused" : "playing")}", () => player.ChildrenOfType<DrawableRuleset>().First().IsPaused.Value == state);
|
AddUntilStep($"game is {(state ? "paused" : "playing")}", () => player.ChildrenOfType<DrawableRuleset>().First().IsPaused.Value == state);
|
||||||
@ -223,7 +223,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
AddStep("send frames", () =>
|
AddStep("send frames", () =>
|
||||||
{
|
{
|
||||||
testSpectatorStreamingClient.SendFrames(streamingUser.Id, nextFrame, count);
|
testSpectatorClient.SendFrames(streamingUser.Id, nextFrame, count);
|
||||||
nextFrame += count;
|
nextFrame += count;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
private IAPIProvider api { get; set; }
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private SpectatorStreamingClient streamingClient { get; set; }
|
private SpectatorClient spectatorClient { get; set; }
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private GameplayBeatmap gameplayBeatmap = new GameplayBeatmap(new Beatmap());
|
private GameplayBeatmap gameplayBeatmap = new GameplayBeatmap(new Beatmap());
|
||||||
@ -69,7 +69,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
replay = new Replay();
|
replay = new Replay();
|
||||||
|
|
||||||
users.BindTo(streamingClient.PlayingUsers);
|
users.BindTo(spectatorClient.PlayingUsers);
|
||||||
users.BindCollectionChanged((obj, args) =>
|
users.BindCollectionChanged((obj, args) =>
|
||||||
{
|
{
|
||||||
switch (args.Action)
|
switch (args.Action)
|
||||||
@ -80,7 +80,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
foreach (int user in args.NewItems)
|
foreach (int user in args.NewItems)
|
||||||
{
|
{
|
||||||
if (user == api.LocalUser.Value.Id)
|
if (user == api.LocalUser.Value.Id)
|
||||||
streamingClient.WatchUser(user);
|
spectatorClient.WatchUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -91,14 +91,14 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
foreach (int user in args.OldItems)
|
foreach (int user in args.OldItems)
|
||||||
{
|
{
|
||||||
if (user == api.LocalUser.Value.Id)
|
if (user == api.LocalUser.Value.Id)
|
||||||
streamingClient.StopWatchingUser(user);
|
spectatorClient.StopWatchingUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
streamingClient.OnNewFrames += onNewFrames;
|
spectatorClient.OnNewFrames += onNewFrames;
|
||||||
|
|
||||||
Add(new GridContainer
|
Add(new GridContainer
|
||||||
{
|
{
|
||||||
@ -189,7 +189,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private double latency = SpectatorStreamingClient.TIME_BETWEEN_SENDS;
|
private double latency = SpectatorClient.TIME_BETWEEN_SENDS;
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
@ -233,7 +233,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddStep("stop recorder", () =>
|
AddStep("stop recorder", () =>
|
||||||
{
|
{
|
||||||
recorder.Expire();
|
recorder.Expire();
|
||||||
streamingClient.OnNewFrames -= onNewFrames;
|
spectatorClient.OnNewFrames -= onNewFrames;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
public class TestSceneMultiSpectatorLeaderboard : MultiplayerTestScene
|
public class TestSceneMultiSpectatorLeaderboard : MultiplayerTestScene
|
||||||
{
|
{
|
||||||
[Cached(typeof(SpectatorStreamingClient))]
|
[Cached(typeof(SpectatorClient))]
|
||||||
private TestSpectatorStreamingClient streamingClient = new TestSpectatorStreamingClient();
|
private TestSpectatorClient spectatorClient = new TestSpectatorClient();
|
||||||
|
|
||||||
[Cached(typeof(UserLookupCache))]
|
[Cached(typeof(UserLookupCache))]
|
||||||
private UserLookupCache lookupCache = new TestUserLookupCache();
|
private UserLookupCache lookupCache = new TestUserLookupCache();
|
||||||
@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
base.Content.AddRange(new Drawable[]
|
base.Content.AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
streamingClient,
|
spectatorClient,
|
||||||
lookupCache,
|
lookupCache,
|
||||||
content = new Container { RelativeSizeAxes = Axes.Both }
|
content = new Container { RelativeSizeAxes = Axes.Both }
|
||||||
});
|
});
|
||||||
@ -59,7 +59,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
foreach (var (userId, clock) in clocks)
|
foreach (var (userId, clock) in clocks)
|
||||||
{
|
{
|
||||||
streamingClient.EndPlay(userId, 0);
|
spectatorClient.EndPlay(userId, 0);
|
||||||
clock.CurrentTime = 0;
|
clock.CurrentTime = 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -67,7 +67,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddStep("create leaderboard", () =>
|
AddStep("create leaderboard", () =>
|
||||||
{
|
{
|
||||||
foreach (var (userId, _) in clocks)
|
foreach (var (userId, _) in clocks)
|
||||||
streamingClient.StartPlay(userId, 0);
|
spectatorClient.StartPlay(userId, 0);
|
||||||
|
|
||||||
Beatmap.Value = CreateWorkingBeatmap(Ruleset.Value);
|
Beatmap.Value = CreateWorkingBeatmap(Ruleset.Value);
|
||||||
|
|
||||||
@ -96,10 +96,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
// For player 2, send frames in sets of 10.
|
// For player 2, send frames in sets of 10.
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
streamingClient.SendFrames(PLAYER_1_ID, i, 1);
|
spectatorClient.SendFrames(PLAYER_1_ID, i, 1);
|
||||||
|
|
||||||
if (i % 10 == 0)
|
if (i % 10 == 0)
|
||||||
streamingClient.SendFrames(PLAYER_2_ID, i, 10);
|
spectatorClient.SendFrames(PLAYER_2_ID, i, 10);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
public class TestSceneMultiSpectatorScreen : MultiplayerTestScene
|
public class TestSceneMultiSpectatorScreen : MultiplayerTestScene
|
||||||
{
|
{
|
||||||
[Cached(typeof(SpectatorStreamingClient))]
|
[Cached(typeof(SpectatorClient))]
|
||||||
private TestSpectatorStreamingClient streamingClient = new TestSpectatorStreamingClient();
|
private TestSpectatorClient spectatorClient = new TestSpectatorClient();
|
||||||
|
|
||||||
[Cached(typeof(UserLookupCache))]
|
[Cached(typeof(UserLookupCache))]
|
||||||
private UserLookupCache lookupCache = new TestUserLookupCache();
|
private UserLookupCache lookupCache = new TestUserLookupCache();
|
||||||
@ -59,14 +59,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
AddStep("add streaming client", () =>
|
AddStep("add streaming client", () =>
|
||||||
{
|
{
|
||||||
Remove(streamingClient);
|
Remove(spectatorClient);
|
||||||
Add(streamingClient);
|
Add(spectatorClient);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("finish previous gameplay", () =>
|
AddStep("finish previous gameplay", () =>
|
||||||
{
|
{
|
||||||
foreach (var id in playingUserIds)
|
foreach (var id in playingUserIds)
|
||||||
streamingClient.EndPlay(id, importedBeatmapId);
|
spectatorClient.EndPlay(id, importedBeatmapId);
|
||||||
playingUserIds.Clear();
|
playingUserIds.Clear();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -87,11 +87,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
loadSpectateScreen(false);
|
loadSpectateScreen(false);
|
||||||
|
|
||||||
AddWaitStep("wait a bit", 10);
|
AddWaitStep("wait a bit", 10);
|
||||||
AddStep("load player first_player_id", () => streamingClient.StartPlay(PLAYER_1_ID, importedBeatmapId));
|
AddStep("load player first_player_id", () => spectatorClient.StartPlay(PLAYER_1_ID, importedBeatmapId));
|
||||||
AddUntilStep("one player added", () => spectatorScreen.ChildrenOfType<Player>().Count() == 1);
|
AddUntilStep("one player added", () => spectatorScreen.ChildrenOfType<Player>().Count() == 1);
|
||||||
|
|
||||||
AddWaitStep("wait a bit", 10);
|
AddWaitStep("wait a bit", 10);
|
||||||
AddStep("load player second_player_id", () => streamingClient.StartPlay(PLAYER_2_ID, importedBeatmapId));
|
AddStep("load player second_player_id", () => spectatorClient.StartPlay(PLAYER_2_ID, importedBeatmapId));
|
||||||
AddUntilStep("two players added", () => spectatorScreen.ChildrenOfType<Player>().Count() == 2);
|
AddUntilStep("two players added", () => spectatorScreen.ChildrenOfType<Player>().Count() == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
foreach (int id in userIds)
|
foreach (int id in userIds)
|
||||||
{
|
{
|
||||||
Client.CurrentMatchPlayingUserIds.Add(id);
|
Client.CurrentMatchPlayingUserIds.Add(id);
|
||||||
streamingClient.StartPlay(id, beatmapId ?? importedBeatmapId);
|
spectatorClient.StartPlay(id, beatmapId ?? importedBeatmapId);
|
||||||
playingUserIds.Add(id);
|
playingUserIds.Add(id);
|
||||||
nextFrame[id] = 0;
|
nextFrame[id] = 0;
|
||||||
}
|
}
|
||||||
@ -262,7 +262,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
AddStep("end play", () =>
|
AddStep("end play", () =>
|
||||||
{
|
{
|
||||||
streamingClient.EndPlay(userId, beatmapId ?? importedBeatmapId);
|
spectatorClient.EndPlay(userId, beatmapId ?? importedBeatmapId);
|
||||||
playingUserIds.Remove(userId);
|
playingUserIds.Remove(userId);
|
||||||
nextFrame.Remove(userId);
|
nextFrame.Remove(userId);
|
||||||
});
|
});
|
||||||
@ -276,7 +276,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
foreach (int id in userIds)
|
foreach (int id in userIds)
|
||||||
{
|
{
|
||||||
streamingClient.SendFrames(id, nextFrame[id], count);
|
spectatorClient.SendFrames(id, nextFrame[id], count);
|
||||||
nextFrame[id] += count;
|
nextFrame[id] += count;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -28,8 +28,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
private const int users = 16;
|
private const int users = 16;
|
||||||
|
|
||||||
[Cached(typeof(SpectatorStreamingClient))]
|
[Cached(typeof(SpectatorClient))]
|
||||||
private TestMultiplayerStreaming streamingClient = new TestMultiplayerStreaming();
|
private TestMultiplayerSpectatorClient spectatorClient = new TestMultiplayerSpectatorClient();
|
||||||
|
|
||||||
[Cached(typeof(UserLookupCache))]
|
[Cached(typeof(UserLookupCache))]
|
||||||
private UserLookupCache lookupCache = new TestSceneCurrentlyPlayingDisplay.TestUserLookupCache();
|
private UserLookupCache lookupCache = new TestSceneCurrentlyPlayingDisplay.TestUserLookupCache();
|
||||||
@ -44,7 +44,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
base.Content.Children = new Drawable[]
|
base.Content.Children = new Drawable[]
|
||||||
{
|
{
|
||||||
streamingClient,
|
spectatorClient,
|
||||||
lookupCache,
|
lookupCache,
|
||||||
Content
|
Content
|
||||||
};
|
};
|
||||||
@ -71,10 +71,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
var playable = Beatmap.Value.GetPlayableBeatmap(Ruleset.Value);
|
var playable = Beatmap.Value.GetPlayableBeatmap(Ruleset.Value);
|
||||||
|
|
||||||
for (int i = 0; i < users; i++)
|
for (int i = 0; i < users; i++)
|
||||||
streamingClient.StartPlay(i, Beatmap.Value.BeatmapInfo.OnlineBeatmapID ?? 0);
|
spectatorClient.StartPlay(i, Beatmap.Value.BeatmapInfo.OnlineBeatmapID ?? 0);
|
||||||
|
|
||||||
Client.CurrentMatchPlayingUserIds.Clear();
|
Client.CurrentMatchPlayingUserIds.Clear();
|
||||||
Client.CurrentMatchPlayingUserIds.AddRange(streamingClient.PlayingUsers);
|
Client.CurrentMatchPlayingUserIds.AddRange(spectatorClient.PlayingUsers);
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -83,7 +83,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
scoreProcessor.ApplyBeatmap(playable);
|
scoreProcessor.ApplyBeatmap(playable);
|
||||||
|
|
||||||
LoadComponentAsync(leaderboard = new MultiplayerGameplayLeaderboard(scoreProcessor, streamingClient.PlayingUsers.ToArray())
|
LoadComponentAsync(leaderboard = new MultiplayerGameplayLeaderboard(scoreProcessor, spectatorClient.PlayingUsers.ToArray())
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
@ -96,7 +96,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestScoreUpdates()
|
public void TestScoreUpdates()
|
||||||
{
|
{
|
||||||
AddRepeatStep("update state", () => streamingClient.RandomlyUpdateState(), 100);
|
AddRepeatStep("update state", () => spectatorClient.RandomlyUpdateState(), 100);
|
||||||
AddToggleStep("switch compact mode", expanded => leaderboard.Expanded.Value = expanded);
|
AddToggleStep("switch compact mode", expanded => leaderboard.Expanded.Value = expanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,12 +109,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestChangeScoringMode()
|
public void TestChangeScoringMode()
|
||||||
{
|
{
|
||||||
AddRepeatStep("update state", () => streamingClient.RandomlyUpdateState(), 5);
|
AddRepeatStep("update state", () => spectatorClient.RandomlyUpdateState(), 5);
|
||||||
AddStep("change to classic", () => config.SetValue(OsuSetting.ScoreDisplayMode, ScoringMode.Classic));
|
AddStep("change to classic", () => config.SetValue(OsuSetting.ScoreDisplayMode, ScoringMode.Classic));
|
||||||
AddStep("change to standardised", () => config.SetValue(OsuSetting.ScoreDisplayMode, ScoringMode.Standardised));
|
AddStep("change to standardised", () => config.SetValue(OsuSetting.ScoreDisplayMode, ScoringMode.Standardised));
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TestMultiplayerStreaming : TestSpectatorStreamingClient
|
public class TestMultiplayerSpectatorClient : TestSpectatorClient
|
||||||
{
|
{
|
||||||
private readonly Dictionary<int, FrameHeader> lastHeaders = new Dictionary<int, FrameHeader>();
|
private readonly Dictionary<int, FrameHeader> lastHeaders = new Dictionary<int, FrameHeader>();
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
public class TestSceneCurrentlyPlayingDisplay : OsuTestScene
|
public class TestSceneCurrentlyPlayingDisplay : OsuTestScene
|
||||||
{
|
{
|
||||||
[Cached(typeof(SpectatorStreamingClient))]
|
[Cached(typeof(SpectatorClient))]
|
||||||
private TestSpectatorStreamingClient testSpectatorStreamingClient = new TestSpectatorStreamingClient();
|
private TestSpectatorClient testSpectatorClient = new TestSpectatorClient();
|
||||||
|
|
||||||
private CurrentlyPlayingDisplay currentlyPlaying;
|
private CurrentlyPlayingDisplay currentlyPlaying;
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
AddStep("add streaming client", () =>
|
AddStep("add streaming client", () =>
|
||||||
{
|
{
|
||||||
nestedContainer?.Remove(testSpectatorStreamingClient);
|
nestedContainer?.Remove(testSpectatorClient);
|
||||||
Remove(lookupCache);
|
Remove(lookupCache);
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -45,7 +45,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
testSpectatorStreamingClient,
|
testSpectatorClient,
|
||||||
currentlyPlaying = new CurrentlyPlayingDisplay
|
currentlyPlaying = new CurrentlyPlayingDisplay
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -55,15 +55,15 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("Reset players", () => testSpectatorStreamingClient.PlayingUsers.Clear());
|
AddStep("Reset players", () => testSpectatorClient.PlayingUsers.Clear());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestBasicDisplay()
|
public void TestBasicDisplay()
|
||||||
{
|
{
|
||||||
AddStep("Add playing user", () => testSpectatorStreamingClient.PlayingUsers.Add(2));
|
AddStep("Add playing user", () => testSpectatorClient.PlayingUsers.Add(2));
|
||||||
AddUntilStep("Panel loaded", () => currentlyPlaying.ChildrenOfType<UserGridPanel>()?.FirstOrDefault()?.User.Id == 2);
|
AddUntilStep("Panel loaded", () => currentlyPlaying.ChildrenOfType<UserGridPanel>()?.FirstOrDefault()?.User.Id == 2);
|
||||||
AddStep("Remove playing user", () => testSpectatorStreamingClient.PlayingUsers.Remove(2));
|
AddStep("Remove playing user", () => testSpectatorClient.PlayingUsers.Remove(2));
|
||||||
AddUntilStep("Panel no longer present", () => !currentlyPlaying.ChildrenOfType<UserGridPanel>().Any());
|
AddUntilStep("Panel no longer present", () => !currentlyPlaying.ChildrenOfType<UserGridPanel>().Any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ using osu.Game.Screens.Play;
|
|||||||
|
|
||||||
namespace osu.Game.Online.Spectator
|
namespace osu.Game.Online.Spectator
|
||||||
{
|
{
|
||||||
public class SpectatorStreamingClient : Component, ISpectatorClient
|
public class SpectatorClient : Component, ISpectatorClient
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum milliseconds between frame bundle sends.
|
/// The maximum milliseconds between frame bundle sends.
|
||||||
@ -80,7 +80,7 @@ namespace osu.Game.Online.Spectator
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action<int, SpectatorState> OnUserFinishedPlaying;
|
public event Action<int, SpectatorState> OnUserFinishedPlaying;
|
||||||
|
|
||||||
public SpectatorStreamingClient(EndpointConfiguration endpoints)
|
public SpectatorClient(EndpointConfiguration endpoints)
|
||||||
{
|
{
|
||||||
endpoint = endpoints.SpectatorEndpointUrl;
|
endpoint = endpoints.SpectatorEndpointUrl;
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ namespace osu.Game.Online.Spectator
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(IAPIProvider api)
|
private void load(IAPIProvider api)
|
||||||
{
|
{
|
||||||
connector = api.GetHubConnector(nameof(SpectatorStreamingClient), endpoint);
|
connector = api.GetHubConnector(nameof(SpectatorClient), endpoint);
|
||||||
|
|
||||||
if (connector != null)
|
if (connector != null)
|
||||||
{
|
{
|
@ -85,7 +85,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
protected IAPIProvider API;
|
protected IAPIProvider API;
|
||||||
|
|
||||||
private SpectatorStreamingClient spectatorStreaming;
|
private SpectatorClient spectatorClient;
|
||||||
private StatefulMultiplayerClient multiplayerClient;
|
private StatefulMultiplayerClient multiplayerClient;
|
||||||
|
|
||||||
protected MenuCursorContainer MenuCursorContainer;
|
protected MenuCursorContainer MenuCursorContainer;
|
||||||
@ -240,7 +240,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
dependencies.CacheAs(API ??= new APIAccess(LocalConfig, endpoints, VersionHash));
|
dependencies.CacheAs(API ??= new APIAccess(LocalConfig, endpoints, VersionHash));
|
||||||
|
|
||||||
dependencies.CacheAs(spectatorStreaming = new SpectatorStreamingClient(endpoints));
|
dependencies.CacheAs(spectatorClient = new SpectatorClient(endpoints));
|
||||||
dependencies.CacheAs(multiplayerClient = new MultiplayerClient(endpoints));
|
dependencies.CacheAs(multiplayerClient = new MultiplayerClient(endpoints));
|
||||||
|
|
||||||
var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures);
|
var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures);
|
||||||
@ -313,7 +313,7 @@ namespace osu.Game
|
|||||||
// add api components to hierarchy.
|
// add api components to hierarchy.
|
||||||
if (API is APIAccess apiAccess)
|
if (API is APIAccess apiAccess)
|
||||||
AddInternal(apiAccess);
|
AddInternal(apiAccess);
|
||||||
AddInternal(spectatorStreaming);
|
AddInternal(spectatorClient);
|
||||||
AddInternal(multiplayerClient);
|
AddInternal(multiplayerClient);
|
||||||
|
|
||||||
AddInternal(RulesetConfigCache);
|
AddInternal(RulesetConfigCache);
|
||||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Dashboard
|
|||||||
private FillFlowContainer<PlayingUserPanel> userFlow;
|
private FillFlowContainer<PlayingUserPanel> userFlow;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private SpectatorStreamingClient spectatorStreaming { get; set; }
|
private SpectatorClient spectatorClient { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
@ -52,7 +52,7 @@ namespace osu.Game.Overlays.Dashboard
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
playingUsers.BindTo(spectatorStreaming.PlayingUsers);
|
playingUsers.BindTo(spectatorClient.PlayingUsers);
|
||||||
playingUsers.BindCollectionChanged(onUsersChanged, true);
|
playingUsers.BindCollectionChanged(onUsersChanged, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
public int RecordFrameRate = 60;
|
public int RecordFrameRate = 60;
|
||||||
|
|
||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private SpectatorStreamingClient spectatorStreaming { get; set; }
|
private SpectatorClient spectatorClient { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private GameplayBeatmap gameplayBeatmap { get; set; }
|
private GameplayBeatmap gameplayBeatmap { get; set; }
|
||||||
@ -49,13 +49,13 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
inputManager = GetContainingInputManager();
|
inputManager = GetContainingInputManager();
|
||||||
|
|
||||||
spectatorStreaming?.BeginPlaying(gameplayBeatmap, target);
|
spectatorClient?.BeginPlaying(gameplayBeatmap, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
spectatorStreaming?.EndPlaying();
|
spectatorClient?.EndPlaying();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
@ -98,7 +98,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
{
|
{
|
||||||
target.Replay.Frames.Add(frame);
|
target.Replay.Frames.Add(frame);
|
||||||
|
|
||||||
spectatorStreaming?.HandleFrame(frame);
|
spectatorClient?.HandleFrame(frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
public bool AllPlayersLoaded => instances.All(p => p?.PlayerLoaded == true);
|
public bool AllPlayersLoaded => instances.All(p => p?.PlayerLoaded == true);
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private SpectatorStreamingClient spectatorClient { get; set; }
|
private SpectatorClient spectatorClient { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private StatefulMultiplayerClient multiplayerClient { get; set; }
|
private StatefulMultiplayerClient multiplayerClient { get; set; }
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
protected readonly Dictionary<int, TrackedUserData> UserScores = new Dictionary<int, TrackedUserData>();
|
protected readonly Dictionary<int, TrackedUserData> UserScores = new Dictionary<int, TrackedUserData>();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private SpectatorStreamingClient streamingClient { get; set; }
|
private SpectatorClient spectatorClient { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private StatefulMultiplayerClient multiplayerClient { get; set; }
|
private StatefulMultiplayerClient multiplayerClient { get; set; }
|
||||||
@ -55,7 +55,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
foreach (var userId in playingUsers)
|
foreach (var userId in playingUsers)
|
||||||
{
|
{
|
||||||
streamingClient.WatchUser(userId);
|
spectatorClient.WatchUser(userId);
|
||||||
|
|
||||||
// probably won't be required in the final implementation.
|
// probably won't be required in the final implementation.
|
||||||
var resolvedUser = userLookupCache.GetUserAsync(userId).Result;
|
var resolvedUser = userLookupCache.GetUserAsync(userId).Result;
|
||||||
@ -88,7 +88,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
playingUsers.BindCollectionChanged(usersChanged);
|
playingUsers.BindCollectionChanged(usersChanged);
|
||||||
|
|
||||||
// this leaderboard should be guaranteed to be completely loaded before the gameplay starts (is a prerequisite in MultiplayerPlayer).
|
// this leaderboard should be guaranteed to be completely loaded before the gameplay starts (is a prerequisite in MultiplayerPlayer).
|
||||||
streamingClient.OnNewFrames += handleIncomingFrames;
|
spectatorClient.OnNewFrames += handleIncomingFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void usersChanged(object sender, NotifyCollectionChangedEventArgs e)
|
private void usersChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||||
@ -98,7 +98,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
case NotifyCollectionChangedAction.Remove:
|
case NotifyCollectionChangedAction.Remove:
|
||||||
foreach (var userId in e.OldItems.OfType<int>())
|
foreach (var userId in e.OldItems.OfType<int>())
|
||||||
{
|
{
|
||||||
streamingClient.StopWatchingUser(userId);
|
spectatorClient.StopWatchingUser(userId);
|
||||||
|
|
||||||
if (UserScores.TryGetValue(userId, out var trackedData))
|
if (UserScores.TryGetValue(userId, out var trackedData))
|
||||||
trackedData.MarkUserQuit();
|
trackedData.MarkUserQuit();
|
||||||
@ -123,14 +123,14 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
if (streamingClient != null)
|
if (spectatorClient != null)
|
||||||
{
|
{
|
||||||
foreach (var user in playingUsers)
|
foreach (var user in playingUsers)
|
||||||
{
|
{
|
||||||
streamingClient.StopWatchingUser(user);
|
spectatorClient.StopWatchingUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
streamingClient.OnNewFrames -= handleIncomingFrames;
|
spectatorClient.OnNewFrames -= handleIncomingFrames;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,12 +31,12 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private SpectatorStreamingClient spectatorStreaming { get; set; }
|
private SpectatorClient spectatorClient { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
spectatorStreaming.OnUserBeganPlaying += userBeganPlaying;
|
spectatorClient.OnUserBeganPlaying += userBeganPlaying;
|
||||||
|
|
||||||
AddInternal(new OsuSpriteText
|
AddInternal(new OsuSpriteText
|
||||||
{
|
{
|
||||||
@ -66,7 +66,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public override bool OnExiting(IScreen next)
|
public override bool OnExiting(IScreen next)
|
||||||
{
|
{
|
||||||
spectatorStreaming.OnUserBeganPlaying -= userBeganPlaying;
|
spectatorClient.OnUserBeganPlaying -= userBeganPlaying;
|
||||||
return base.OnExiting(next);
|
return base.OnExiting(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,8 +84,8 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
if (spectatorStreaming != null)
|
if (spectatorClient != null)
|
||||||
spectatorStreaming.OnUserBeganPlaying -= userBeganPlaying;
|
spectatorClient.OnUserBeganPlaying -= userBeganPlaying;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,12 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private SpectatorStreamingClient spectatorStreaming { get; set; }
|
private SpectatorClient spectatorClient { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
spectatorStreaming.OnUserBeganPlaying += userBeganPlaying;
|
spectatorClient.OnUserBeganPlaying += userBeganPlaying;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void userBeganPlaying(int userId, SpectatorState state)
|
private void userBeganPlaying(int userId, SpectatorState state)
|
||||||
@ -40,8 +40,8 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
if (spectatorStreaming != null)
|
if (spectatorClient != null)
|
||||||
spectatorStreaming.OnUserBeganPlaying -= userBeganPlaying;
|
spectatorClient.OnUserBeganPlaying -= userBeganPlaying;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Screens.Spectate
|
|||||||
private RulesetStore rulesets { get; set; }
|
private RulesetStore rulesets { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private SpectatorStreamingClient spectatorClient { get; set; }
|
private SpectatorClient spectatorClient { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private UserLookupCache userLookupCache { get; set; }
|
private UserLookupCache userLookupCache { get; set; }
|
||||||
|
@ -12,7 +12,7 @@ using osu.Game.Scoring;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Spectator
|
namespace osu.Game.Tests.Visual.Spectator
|
||||||
{
|
{
|
||||||
public class TestSpectatorStreamingClient : SpectatorStreamingClient
|
public class TestSpectatorClient : SpectatorClient
|
||||||
{
|
{
|
||||||
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>();
|
||||||
@ -20,7 +20,7 @@ namespace osu.Game.Tests.Visual.Spectator
|
|||||||
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 TestSpectatorStreamingClient()
|
public TestSpectatorClient()
|
||||||
: base(new DevelopmentEndpointConfiguration())
|
: base(new DevelopmentEndpointConfiguration())
|
||||||
{
|
{
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user