mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 15:07:44 +08:00
Merge pull request #21588 from smoogipoo/beginplaying-score-token
Add score token to `BeginPlaySession()`
This commit is contained in:
commit
9d14292320
@ -261,7 +261,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestFinalFramesPurgedBeforeEndingPlay()
|
public void TestFinalFramesPurgedBeforeEndingPlay()
|
||||||
{
|
{
|
||||||
AddStep("begin playing", () => spectatorClient.BeginPlaying(TestGameplayState.Create(new OsuRuleset()), new Score()));
|
AddStep("begin playing", () => spectatorClient.BeginPlaying(0, TestGameplayState.Create(new OsuRuleset()), new Score()));
|
||||||
|
|
||||||
AddStep("send frames and finish play", () =>
|
AddStep("send frames and finish play", () =>
|
||||||
{
|
{
|
||||||
|
@ -147,7 +147,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
spectatorClient.BeginPlaying(TestGameplayState.Create(new OsuRuleset()), recordingScore);
|
spectatorClient.BeginPlaying(0, TestGameplayState.Create(new OsuRuleset()), recordingScore);
|
||||||
spectatorClient.OnNewFrames += onNewFrames;
|
spectatorClient.OnNewFrames += onNewFrames;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,9 @@ namespace osu.Game.Online.Spectator
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Signal the start of a new play session.
|
/// Signal the start of a new play session.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="scoreToken">The score submission token.</param>
|
||||||
/// <param name="state">The state of gameplay.</param>
|
/// <param name="state">The state of gameplay.</param>
|
||||||
Task BeginPlaySession(SpectatorState state);
|
Task BeginPlaySession(long? scoreToken, SpectatorState state);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Send a bundle of frame data for the current play session.
|
/// Send a bundle of frame data for the current play session.
|
||||||
|
@ -47,7 +47,7 @@ namespace osu.Game.Online.Spectator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task BeginPlayingInternal(SpectatorState state)
|
protected override async Task BeginPlayingInternal(long? scoreToken, SpectatorState state)
|
||||||
{
|
{
|
||||||
if (!IsConnected.Value)
|
if (!IsConnected.Value)
|
||||||
return;
|
return;
|
||||||
@ -56,7 +56,7 @@ namespace osu.Game.Online.Spectator
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await connection.InvokeAsync(nameof(ISpectatorServer.BeginPlaySession), state);
|
await connection.InvokeAsync(nameof(ISpectatorServer.BeginPlaySession), scoreToken, state);
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@ -65,7 +65,7 @@ namespace osu.Game.Online.Spectator
|
|||||||
Debug.Assert(connector != null);
|
Debug.Assert(connector != null);
|
||||||
|
|
||||||
await connector.Reconnect();
|
await connector.Reconnect();
|
||||||
await BeginPlayingInternal(state);
|
await BeginPlayingInternal(scoreToken, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exceptions can occur if, for instance, the locally played beatmap doesn't have a server-side counterpart.
|
// Exceptions can occur if, for instance, the locally played beatmap doesn't have a server-side counterpart.
|
||||||
|
@ -76,6 +76,7 @@ namespace osu.Game.Online.Spectator
|
|||||||
|
|
||||||
private IBeatmap? currentBeatmap;
|
private IBeatmap? currentBeatmap;
|
||||||
private Score? currentScore;
|
private Score? currentScore;
|
||||||
|
private long? currentScoreToken;
|
||||||
|
|
||||||
private readonly Queue<FrameDataBundle> pendingFrameBundles = new Queue<FrameDataBundle>();
|
private readonly Queue<FrameDataBundle> pendingFrameBundles = new Queue<FrameDataBundle>();
|
||||||
|
|
||||||
@ -108,7 +109,7 @@ namespace osu.Game.Online.Spectator
|
|||||||
// re-send state in case it wasn't received
|
// re-send state in case it wasn't received
|
||||||
if (IsPlaying)
|
if (IsPlaying)
|
||||||
// TODO: this is likely sent out of order after a reconnect scenario. needs further consideration.
|
// TODO: this is likely sent out of order after a reconnect scenario. needs further consideration.
|
||||||
BeginPlayingInternal(currentState);
|
BeginPlayingInternal(currentScoreToken, currentState);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -159,7 +160,7 @@ namespace osu.Game.Online.Spectator
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BeginPlaying(GameplayState state, Score score)
|
public void BeginPlaying(long? scoreToken, GameplayState state, Score score)
|
||||||
{
|
{
|
||||||
// This schedule is only here to match the one below in `EndPlaying`.
|
// This schedule is only here to match the one below in `EndPlaying`.
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
@ -178,8 +179,9 @@ namespace osu.Game.Online.Spectator
|
|||||||
|
|
||||||
currentBeatmap = state.Beatmap;
|
currentBeatmap = state.Beatmap;
|
||||||
currentScore = score;
|
currentScore = score;
|
||||||
|
currentScoreToken = scoreToken;
|
||||||
|
|
||||||
BeginPlayingInternal(currentState);
|
BeginPlayingInternal(currentScoreToken, currentState);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +266,7 @@ namespace osu.Game.Online.Spectator
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Task BeginPlayingInternal(SpectatorState state);
|
protected abstract Task BeginPlayingInternal(long? scoreToken, SpectatorState state);
|
||||||
|
|
||||||
protected abstract Task SendFramesInternal(FrameDataBundle bundle);
|
protected abstract Task SendFramesInternal(FrameDataBundle bundle);
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ namespace osu.Game.Screens.Play
|
|||||||
realmBeatmap.LastPlayed = DateTimeOffset.Now;
|
realmBeatmap.LastPlayed = DateTimeOffset.Now;
|
||||||
});
|
});
|
||||||
|
|
||||||
spectatorClient.BeginPlaying(GameplayState, Score);
|
spectatorClient.BeginPlaying(token, GameplayState, Score);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool OnExiting(ScreenExitEvent e)
|
public override bool OnExiting(ScreenExitEvent e)
|
||||||
|
@ -126,7 +126,7 @@ namespace osu.Game.Tests.Visual.Spectator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Task BeginPlayingInternal(SpectatorState state)
|
protected override Task BeginPlayingInternal(long? scoreToken, SpectatorState state)
|
||||||
{
|
{
|
||||||
// Track the local user's playing beatmap ID.
|
// Track the local user's playing beatmap ID.
|
||||||
Debug.Assert(state.BeatmapID != null);
|
Debug.Assert(state.BeatmapID != null);
|
||||||
|
Loading…
Reference in New Issue
Block a user