Expose events from streaming client

This commit is contained in:
Dean Herbert 2020-10-26 20:05:11 +09:00
parent 5fd97bd043
commit 154ccf1b49
1 changed files with 16 additions and 0 deletions

View File

@ -64,6 +64,16 @@ public class SpectatorStreamingClient : Component, ISpectatorClient
/// </summary>
public event Action<int, FrameDataBundle> OnNewFrames;
/// <summary>
/// Called whenever a user starts a play session.
/// </summary>
public event Action<int, SpectatorState> OnUserBeganPlaying;
/// <summary>
/// Called whenever a user starts a play session.
/// </summary>
public event Action<int, SpectatorState> OnUserFinishedPlaying;
[BackgroundDependencyLoader]
private void load()
{
@ -154,18 +164,24 @@ Task ISpectatorClient.UserBeganPlaying(int userId, SpectatorState state)
if (!playingUsers.Contains(userId))
playingUsers.Add(userId);
OnUserBeganPlaying?.Invoke(userId, state);
return Task.CompletedTask;
}
Task ISpectatorClient.UserFinishedPlaying(int userId, SpectatorState state)
{
playingUsers.Remove(userId);
OnUserFinishedPlaying?.Invoke(userId, state);
return Task.CompletedTask;
}
Task ISpectatorClient.UserSentFrames(int userId, FrameDataBundle data)
{
OnNewFrames?.Invoke(userId, data);
return Task.CompletedTask;
}