mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Add return bool to HandleRequest to better trigger failures
This commit is contained in:
@ -34,8 +34,9 @@ namespace osu.Game.Online.API
|
||||
|
||||
/// <summary>
|
||||
/// Provide handling logic for an arbitrary API request.
|
||||
/// Should return true is a request was handled. If null or false return, the request will be failed with a <see cref="NotSupportedException"/>.
|
||||
/// </summary>
|
||||
public Action<APIRequest> HandleRequest;
|
||||
public Func<APIRequest, bool> HandleRequest;
|
||||
|
||||
private readonly Bindable<APIState> state = new Bindable<APIState>(APIState.Online);
|
||||
|
||||
@ -55,12 +56,12 @@ namespace osu.Game.Online.API
|
||||
|
||||
public virtual void Queue(APIRequest request)
|
||||
{
|
||||
if (HandleRequest != null)
|
||||
HandleRequest.Invoke(request);
|
||||
else
|
||||
if (HandleRequest?.Invoke(request) != true)
|
||||
{
|
||||
// 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);
|
||||
|
Reference in New Issue
Block a user