Merge pull request #1422 from peppy/fix-api-init-requests

Fix multiple requests potentially being triggered during connect sequence
This commit is contained in:
Dan Balasescu 2017-10-24 19:52:45 +09:00 committed by GitHub
commit 93f691a487

View File

@ -121,18 +121,28 @@ namespace osu.Game.Online.API
continue;
}
var userReq = new GetUserRequest();
userReq.Success += u =>
{
LocalUser.Value = u;
failureCount = 0;
//we're connected!
State = APIState.Online;
failureCount = 0;
};
if (!handleRequest(userReq))
{
Thread.Sleep(500);
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.
while (State != APIState.Online)
Thread.Sleep(500);
break;
}