Add score processed callback to spectator client

This commit is contained in:
Bartłomiej Dach 2022-12-20 21:23:50 +01:00
parent d81a724dd7
commit b03291330f
No known key found for this signature in database
3 changed files with 20 additions and 0 deletions

View File

@ -32,5 +32,12 @@ namespace osu.Game.Online.Spectator
/// <param name="userId">The user.</param>
/// <param name="data">The frame data.</param>
Task UserSentFrames(int userId, FrameDataBundle data);
/// <summary>
/// Signals that a user's submitted score was fully processed.
/// </summary>
/// <param name="userId">The ID of the user who achieved the score.</param>
/// <param name="scoreId">The ID of the score.</param>
Task UserScoreProcessed(int userId, long scoreId);
}
}

View File

@ -41,6 +41,7 @@ namespace osu.Game.Online.Spectator
connection.On<int, SpectatorState>(nameof(ISpectatorClient.UserBeganPlaying), ((ISpectatorClient)this).UserBeganPlaying);
connection.On<int, FrameDataBundle>(nameof(ISpectatorClient.UserSentFrames), ((ISpectatorClient)this).UserSentFrames);
connection.On<int, SpectatorState>(nameof(ISpectatorClient.UserFinishedPlaying), ((ISpectatorClient)this).UserFinishedPlaying);
connection.On<int, long>(nameof(ISpectatorClient.UserScoreProcessed), ((ISpectatorClient)this).UserScoreProcessed);
};
IsConnected.BindTo(connector.IsConnected);

View File

@ -64,6 +64,11 @@ namespace osu.Game.Online.Spectator
/// </summary>
public virtual event Action<int, SpectatorState>? OnUserFinishedPlaying;
/// <summary>
/// Called whenever a user-submitted score has been fully processed.
/// </summary>
public virtual event Action<int, long>? OnUserScoreProcessed;
/// <summary>
/// A dictionary containing all users currently being watched, with the number of watching components for each user.
/// </summary>
@ -160,6 +165,13 @@ namespace osu.Game.Online.Spectator
return Task.CompletedTask;
}
Task ISpectatorClient.UserScoreProcessed(int userId, long scoreId)
{
Schedule(() => OnUserScoreProcessed?.Invoke(userId, scoreId));
return Task.CompletedTask;
}
public void BeginPlaying(long? scoreToken, GameplayState state, Score score)
{
// This schedule is only here to match the one below in `EndPlaying`.