mirror of
https://github.com/ppy/osu
synced 2025-02-21 13:07:18 +00:00
Fail all API requests sent to DummyAPIAccess
Until now, API requests sent to dummy API were just lost in the void. In most cases this somehow worked as expected, but any logic which is waiting on a request to finish will potentially never get a response. Going forward, I'm not 100% sure that every `Wait` on a web response will have local timeout logic (I think there is a certain amount of assumption that this is being managed for us by `APIAccess`), so I've made this change to better handle such cases going forward. Now, rather than nothing happening, requests will trigger a failure via the existing exception logic rather than silently pretending the request never arrived.
This commit is contained in:
parent
3594c42b79
commit
f5ba746ae5
@ -181,9 +181,13 @@ namespace osu.Game.Online.API
|
||||
/// <returns>Whether we are in a failed or cancelled state.</returns>
|
||||
private bool checkAndScheduleFailure()
|
||||
{
|
||||
if (API == null || pendingFailure == null) return cancelled;
|
||||
if (pendingFailure == null) return cancelled;
|
||||
|
||||
if (API == null)
|
||||
pendingFailure();
|
||||
else
|
||||
API.Schedule(pendingFailure);
|
||||
|
||||
API.Schedule(pendingFailure);
|
||||
pendingFailure = null;
|
||||
return true;
|
||||
}
|
||||
|
@ -55,7 +55,12 @@ namespace osu.Game.Online.API
|
||||
|
||||
public virtual void Queue(APIRequest request)
|
||||
{
|
||||
HandleRequest?.Invoke(request);
|
||||
if (HandleRequest != null)
|
||||
HandleRequest.Invoke(request);
|
||||
else
|
||||
// this will fail due to not receiving an APIAccess, and trigger a failure on the request.
|
||||
// this is intended - any request in testing that needs non-failures should use HandleRequest.
|
||||
request.Perform(this);
|
||||
}
|
||||
|
||||
public void Perform(APIRequest request) => HandleRequest?.Invoke(request);
|
||||
|
Loading…
Reference in New Issue
Block a user