mirror of
https://github.com/ppy/osu
synced 2025-01-05 13:50:03 +00:00
Standardise and extract common connection failure handling logic
This commit is contained in:
parent
d36169f697
commit
57c5d45c02
@ -153,8 +153,7 @@ namespace osu.Game.Online.API
|
||||
|
||||
if (!handleRequest(userReq))
|
||||
{
|
||||
if (State.Value == APIState.Connecting)
|
||||
state.Value = APIState.Failing;
|
||||
failConnectionProcess();
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -170,7 +169,11 @@ namespace osu.Game.Online.API
|
||||
};
|
||||
|
||||
if (!handleRequest(friendsReq))
|
||||
state.Value = APIState.Failing;
|
||||
{
|
||||
failConnectionProcess();
|
||||
continue;
|
||||
}
|
||||
|
||||
// The Success callback event is fired on the main thread, so we should wait for that to run before proceeding.
|
||||
// Without this, we will end up circulating this Connecting loop multiple times and queueing up many web requests
|
||||
// before actually going online.
|
||||
@ -203,6 +206,13 @@ namespace osu.Game.Online.API
|
||||
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
|
||||
void failConnectionProcess()
|
||||
{
|
||||
// if something went wrong during the connection process, we want to reset the state (but only if still connecting).
|
||||
if (State.Value == APIState.Connecting)
|
||||
state.Value = APIState.Failing;
|
||||
}
|
||||
}
|
||||
|
||||
public void Perform(APIRequest request)
|
||||
|
Loading…
Reference in New Issue
Block a user