1
0
mirror of https://github.com/ppy/osu synced 2025-03-20 01:49:41 +00:00

Move disconnect logic inside connection loop to ensure previous connection is disposed

This commit is contained in:
Dean Herbert 2021-01-26 18:59:42 +09:00
parent 0f09a7feb9
commit b573c96c07

View File

@ -71,14 +71,15 @@ namespace osu.Game.Online.Multiplayer
try
{
await disconnect(false);
// this token will be valid for the scope of this connection.
// if cancelled, we can be sure that a disconnect or reconnect is handled elsewhere.
var cancellationToken = connectCancelSource.Token;
while (api.State.Value == APIState.Online)
{
// ensure any previous connection was disposed.
await disconnect(false);
cancellationToken.ThrowIfCancellationRequested();
Logger.Log("Multiplayer client connecting...", LoggingTarget.Network);