Use a task chain and fix potential misordering of events

This commit is contained in:
smoogipoo
2021-01-25 20:41:51 +09:00
parent 76e1f6e57b
commit 964976f604
4 changed files with 70 additions and 96 deletions

View File

@ -134,17 +134,12 @@ namespace osu.Game.Online.Multiplayer
return connection.InvokeAsync<MultiplayerRoom>(nameof(IMultiplayerServer.JoinRoom), roomId);
}
public override async Task LeaveRoom()
protected override Task LeaveRoomInternal()
{
if (!isConnected.Value)
{
// even if not connected, make sure the local room state can be cleaned up.
await base.LeaveRoom();
return;
}
return Task.FromCanceled(new CancellationToken(true));
await base.LeaveRoom();
await connection.InvokeAsync(nameof(IMultiplayerServer.LeaveRoom));
return connection.InvokeAsync(nameof(IMultiplayerServer.LeaveRoom));
}
public override Task TransferHost(int userId)