mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 16:16:07 +08:00
Make token private
This commit is contained in:
parent
a0c6c4da35
commit
84b2f9a848
@ -67,8 +67,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
{
|
{
|
||||||
base.LoadAsyncComplete();
|
base.LoadAsyncComplete();
|
||||||
|
|
||||||
if (Token == null)
|
if (!ValidForResume)
|
||||||
return; // Todo: Somehow handle token retrieval failure.
|
return; // token retrieval may have failed.
|
||||||
|
|
||||||
client.MatchStarted += onMatchStarted;
|
client.MatchStarted += onMatchStarted;
|
||||||
client.ResultsReady += onResultsReady;
|
client.ResultsReady += onResultsReady;
|
||||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Screens.Play
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The token to be used for the current submission. This is fetched via a request created by <see cref="CreateTokenRequest"/>.
|
/// The token to be used for the current submission. This is fetched via a request created by <see cref="CreateTokenRequest"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected long? Token { get; private set; }
|
private long? token;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; }
|
private IAPIProvider api { get; set; }
|
||||||
@ -38,7 +38,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
if (!api.IsLoggedIn)
|
if (!api.IsLoggedIn)
|
||||||
{
|
{
|
||||||
handleFailure(new InvalidOperationException("API is not online."));
|
handleTokenFailure(new InvalidOperationException("API is not online."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,22 +46,24 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
if (req == null)
|
if (req == null)
|
||||||
{
|
{
|
||||||
handleFailure(new InvalidOperationException("Request could not be constructed."));
|
handleTokenFailure(new InvalidOperationException("Request could not be constructed."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
req.Success += r =>
|
req.Success += r =>
|
||||||
{
|
{
|
||||||
Token = r.ID;
|
token = r.ID;
|
||||||
tcs.SetResult(true);
|
tcs.SetResult(true);
|
||||||
};
|
};
|
||||||
req.Failure += handleFailure;
|
req.Failure += handleTokenFailure;
|
||||||
|
|
||||||
api.Queue(req);
|
api.Queue(req);
|
||||||
|
|
||||||
tcs.Task.Wait();
|
tcs.Task.Wait();
|
||||||
|
|
||||||
void handleFailure(Exception exception)
|
base.LoadAsyncComplete();
|
||||||
|
|
||||||
|
void handleTokenFailure(Exception exception)
|
||||||
{
|
{
|
||||||
if (HandleTokenRetrievalFailure(exception))
|
if (HandleTokenRetrievalFailure(exception))
|
||||||
{
|
{
|
||||||
@ -79,8 +81,6 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
tcs.SetResult(false);
|
tcs.SetResult(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
base.LoadAsyncComplete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -95,11 +95,11 @@ namespace osu.Game.Screens.Play
|
|||||||
await base.PrepareScoreForResultsAsync(score).ConfigureAwait(false);
|
await base.PrepareScoreForResultsAsync(score).ConfigureAwait(false);
|
||||||
|
|
||||||
// token may be null if the request failed but gameplay was still allowed (see HandleTokenRetrievalFailure).
|
// token may be null if the request failed but gameplay was still allowed (see HandleTokenRetrievalFailure).
|
||||||
if (Token == null)
|
if (token == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var tcs = new TaskCompletionSource<bool>();
|
var tcs = new TaskCompletionSource<bool>();
|
||||||
var request = CreateSubmissionRequest(score, Token.Value);
|
var request = CreateSubmissionRequest(score, token.Value);
|
||||||
|
|
||||||
request.Success += s =>
|
request.Success += s =>
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user