mirror of
https://github.com/ppy/osu
synced 2025-01-03 04:42:10 +00:00
Rename APIRequest.Result
to Response
This commit is contained in:
parent
4bd1083388
commit
b41fa41c85
@ -42,7 +42,7 @@ namespace osu.Game.Tests.Online
|
|||||||
|
|
||||||
AddAssert("response event fired", () => response != null);
|
AddAssert("response event fired", () => response != null);
|
||||||
|
|
||||||
AddAssert("request has response", () => request.Result == response);
|
AddAssert("request has response", () => request.Response == response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -72,7 +72,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
var req = new GetBeatmapSetRequest(1);
|
var req = new GetBeatmapSetRequest(1);
|
||||||
api.Queue(req);
|
api.Queue(req);
|
||||||
|
|
||||||
AddUntilStep("wait for api response", () => req.Result != null);
|
AddUntilStep("wait for api response", () => req.Response != null);
|
||||||
|
|
||||||
TestUpdateableBeatmapBackgroundSprite background = null;
|
TestUpdateableBeatmapBackgroundSprite background = null;
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
Child = background = new TestUpdateableBeatmapBackgroundSprite
|
Child = background = new TestUpdateableBeatmapBackgroundSprite
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Beatmap = { Value = new BeatmapInfo { BeatmapSet = req.Result?.ToBeatmapSet(rulesets) } }
|
Beatmap = { Value = new BeatmapInfo { BeatmapSet = req.Response?.ToBeatmapSet(rulesets) } }
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ namespace osu.Game.Tournament
|
|||||||
{
|
{
|
||||||
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = b.ID });
|
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = b.ID });
|
||||||
API.Perform(req);
|
API.Perform(req);
|
||||||
b.BeatmapInfo = req.Result?.ToBeatmapInfo(RulesetStore);
|
b.BeatmapInfo = req.Response?.ToBeatmapInfo(RulesetStore);
|
||||||
|
|
||||||
addedInfo = true;
|
addedInfo = true;
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ namespace osu.Game.Tournament
|
|||||||
{
|
{
|
||||||
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = b.ID });
|
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = b.ID });
|
||||||
req.Perform(API);
|
req.Perform(API);
|
||||||
b.BeatmapInfo = req.Result?.ToBeatmapInfo(RulesetStore);
|
b.BeatmapInfo = req.Response?.ToBeatmapInfo(RulesetStore);
|
||||||
|
|
||||||
addedInfo = true;
|
addedInfo = true;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ namespace osu.Game.Beatmaps
|
|||||||
// intentionally blocking to limit web request concurrency
|
// intentionally blocking to limit web request concurrency
|
||||||
api.Perform(req);
|
api.Perform(req);
|
||||||
|
|
||||||
var res = req.Result;
|
var res = req.Response;
|
||||||
|
|
||||||
if (res != null)
|
if (res != null)
|
||||||
{
|
{
|
||||||
|
@ -115,7 +115,7 @@ namespace osu.Game.Database
|
|||||||
createNewTask();
|
createNewTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<User> foundUsers = request.Result?.Users;
|
List<User> foundUsers = request.Response?.Users;
|
||||||
|
|
||||||
if (foundUsers != null)
|
if (foundUsers != null)
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.IO.Network;
|
using osu.Framework.IO.Network;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
@ -17,7 +18,11 @@ namespace osu.Game.Online.API
|
|||||||
{
|
{
|
||||||
protected override WebRequest CreateWebRequest() => new OsuJsonWebRequest<T>(Uri);
|
protected override WebRequest CreateWebRequest() => new OsuJsonWebRequest<T>(Uri);
|
||||||
|
|
||||||
public T Result { get; private set; }
|
/// <summary>
|
||||||
|
/// The deserialised response object. May be null if the request or deserialisation failed.
|
||||||
|
/// </summary>
|
||||||
|
[CanBeNull]
|
||||||
|
public T Response { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked on successful completion of an API request.
|
/// Invoked on successful completion of an API request.
|
||||||
@ -27,21 +32,21 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
protected APIRequest()
|
protected APIRequest()
|
||||||
{
|
{
|
||||||
base.Success += () => Success?.Invoke(Result);
|
base.Success += () => Success?.Invoke(Response);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PostProcess()
|
protected override void PostProcess()
|
||||||
{
|
{
|
||||||
base.PostProcess();
|
base.PostProcess();
|
||||||
Result = ((OsuJsonWebRequest<T>)WebRequest)?.ResponseObject;
|
Response = ((OsuJsonWebRequest<T>)WebRequest)?.ResponseObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void TriggerSuccess(T result)
|
internal void TriggerSuccess(T result)
|
||||||
{
|
{
|
||||||
if (Result != null)
|
if (Response != null)
|
||||||
throw new InvalidOperationException("Attempted to trigger success more than once");
|
throw new InvalidOperationException("Attempted to trigger success more than once");
|
||||||
|
|
||||||
Result = result;
|
Response = result;
|
||||||
|
|
||||||
TriggerSuccess();
|
TriggerSuccess();
|
||||||
}
|
}
|
||||||
|
@ -146,16 +146,16 @@ namespace osu.Game.Overlays
|
|||||||
switch (userRequest.Type)
|
switch (userRequest.Type)
|
||||||
{
|
{
|
||||||
case UserRankingsType.Performance:
|
case UserRankingsType.Performance:
|
||||||
return new PerformanceTable(1, userRequest.Result.Users);
|
return new PerformanceTable(1, userRequest.Response.Users);
|
||||||
|
|
||||||
case UserRankingsType.Score:
|
case UserRankingsType.Score:
|
||||||
return new ScoresTable(1, userRequest.Result.Users);
|
return new ScoresTable(1, userRequest.Response.Users);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
case GetCountryRankingsRequest countryRequest:
|
case GetCountryRankingsRequest countryRequest:
|
||||||
return new CountriesTable(1, countryRequest.Result.Countries);
|
return new CountriesTable(1, countryRequest.Response.Countries);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -66,7 +66,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
|
|
||||||
req.Failure += exception =>
|
req.Failure += exception =>
|
||||||
{
|
{
|
||||||
onError?.Invoke(req.Result?.Error ?? exception.Message);
|
onError?.Invoke(req.Response?.Error ?? exception.Message);
|
||||||
};
|
};
|
||||||
|
|
||||||
api.Queue(req);
|
api.Queue(req);
|
||||||
|
Loading…
Reference in New Issue
Block a user