mirror of
https://github.com/ppy/osu
synced 2025-01-31 10:22:02 +00:00
Fix API potentially getting stuck in connecting state
This commit is contained in:
parent
9c22753f3f
commit
8a01e567a1
@ -145,16 +145,14 @@ namespace osu.Game.Online.API
|
||||
|
||||
failureCount = 0;
|
||||
|
||||
var friendsReq = new GetFriendsRequest();
|
||||
friendsReq.Success += f =>
|
||||
fetchFriends(() =>
|
||||
{
|
||||
Friends.AddRange(f);
|
||||
|
||||
//we're connected!
|
||||
state.Value = APIState.Online;
|
||||
};
|
||||
|
||||
handleRequest(friendsReq);
|
||||
}, () =>
|
||||
{
|
||||
state.Value = APIState.Failing;
|
||||
});
|
||||
};
|
||||
|
||||
if (!handleRequest(userReq))
|
||||
@ -255,6 +253,19 @@ namespace osu.Game.Online.API
|
||||
return null;
|
||||
}
|
||||
|
||||
private void fetchFriends(Action onSuccess, Action onFail)
|
||||
{
|
||||
var friendsReq = new GetFriendsRequest();
|
||||
friendsReq.Success += res =>
|
||||
{
|
||||
Friends.AddRange(res);
|
||||
onSuccess?.Invoke();
|
||||
};
|
||||
|
||||
if (!handleRequest(friendsReq))
|
||||
onFail?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle a single API request.
|
||||
/// Ensures all exceptions are caught and dealt with correctly.
|
||||
|
Loading…
Reference in New Issue
Block a user