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:
Dean Herbert 2021-03-23 17:31:28 +09:00
parent 3594c42b79
commit f5ba746ae5
2 changed files with 12 additions and 3 deletions

View File

@ -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;
}

View File

@ -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);