Merge remote-tracking branch 'origin/master' into user-registration

This commit is contained in:
smoogipoo
2018-12-22 17:19:28 +09:00
71 changed files with 1232 additions and 423 deletions

View File

@ -104,7 +104,7 @@ namespace osu.Game.Online.API
if (queue.Count == 0)
{
log.Add(@"Queueing a ping request");
Queue(new ListChannelsRequest { Timeout = 5000 });
Queue(new GetUserRequest());
}
break;
@ -175,7 +175,6 @@ namespace osu.Game.Online.API
req = queue.Dequeue();
}
// TODO: handle failures better
handleRequest(req);
}
@ -226,45 +225,30 @@ namespace osu.Game.Online.API
/// <summary>
/// Handle a single API request.
/// Ensures all exceptions are caught and dealt with correctly.
/// </summary>
/// <param name="req">The request.</param>
/// <returns>true if we should remove this request from the queue.</returns>
/// <returns>true if the request succeeded.</returns>
private bool handleRequest(APIRequest req)
{
try
{
Logger.Log($@"Performing request {req}", LoggingTarget.Network);
req.Failure += ex =>
{
if (ex is WebException we)
handleWebException(we);
};
req.Perform(this);
//we could still be in initialisation, at which point we don't want to say we're Online yet.
if (IsLoggedIn)
State = APIState.Online;
if (IsLoggedIn) State = APIState.Online;
failureCount = 0;
return true;
}
catch (WebException we)
{
var removeFromQueue = handleWebException(we);
if (removeFromQueue)
req.Fail(we);
return removeFromQueue;
handleWebException(we);
return false;
}
catch (Exception e)
{
if (e is TimeoutException)
log.Add(@"API level timeout exception was hit");
req.Fail(e);
return true;
return false;
}
}
@ -319,8 +303,12 @@ namespace osu.Game.Online.API
//we might try again at an api level.
return false;
State = APIState.Failing;
flushQueue();
if (State == APIState.Online)
{
State = APIState.Failing;
flushQueue();
}
return true;
}