Fix connection loop always getting a cancelled token

This commit is contained in:
Bartłomiej Dach 2021-01-26 21:26:50 +01:00
parent b573c96c07
commit 4d4d97661e

View File

@ -71,15 +71,16 @@ namespace osu.Game.Online.Multiplayer
try
{
// 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.
// this will also create a new cancellation token source.
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;
cancellationToken.ThrowIfCancellationRequested();
Logger.Log("Multiplayer client connecting...", LoggingTarget.Network);