1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-28 11:50:15 +08:00

Watch global user presence while in spectator screen

This commit is contained in:
Dan Balasescu
2025-02-04 17:55:50 +09:00
Unverified
parent 61419ec9c8
commit 2f90bb4d67
@@ -12,6 +12,7 @@ using osu.Framework.Extensions.ObjectExtensions;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Metadata;
using osu.Game.Online.Spectator;
using osu.Game.Replays;
using osu.Game.Rulesets;
@@ -38,6 +39,9 @@ namespace osu.Game.Screens.Spectate
[Resolved]
private SpectatorClient spectatorClient { get; set; } = null!;
[Resolved]
private MetadataClient metadataClient { get; set; } = null!;
[Resolved]
private UserLookupCache userLookupCache { get; set; } = null!;
@@ -50,6 +54,7 @@ namespace osu.Game.Screens.Spectate
private readonly Dictionary<int, SpectatorGameplayState> gameplayStates = new Dictionary<int, SpectatorGameplayState>();
private IDisposable? realmSubscription;
private IDisposable? userWatchToken;
/// <summary>
/// Creates a new <see cref="SpectatorScreen"/>.
@@ -64,6 +69,8 @@ namespace osu.Game.Screens.Spectate
{
base.LoadComplete();
userWatchToken = metadataClient.BeginWatchingUserPresence();
userLookupCache.GetUsersAsync(users.ToArray()).ContinueWith(task => Schedule(() =>
{
var foundUsers = task.GetResultSafely();
@@ -282,6 +289,7 @@ namespace osu.Game.Screens.Spectate
}
realmSubscription?.Dispose();
userWatchToken?.Dispose();
}
}
}