mirror of
https://github.com/osukey/osukey.git
synced 2025-06-08 04:48:04 +09: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 (!handleRequest(userReq))
|
||||||
{
|
{
|
||||||
if (State.Value == APIState.Connecting)
|
failConnectionProcess();
|
||||||
state.Value = APIState.Failing;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +169,11 @@ namespace osu.Game.Online.API
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (!handleRequest(friendsReq))
|
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.
|
// 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
|
// Without this, we will end up circulating this Connecting loop multiple times and queueing up many web requests
|
||||||
// before actually going online.
|
// before actually going online.
|
||||||
@ -203,6 +206,13 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
Thread.Sleep(50);
|
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)
|
public void Perform(APIRequest request)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user