1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 05:27:23 +08:00

Ensure the current room is left at a mutliplayer client level on client disconnection

This commit is contained in:
Dean Herbert 2020-12-23 15:49:22 +09:00
parent b632e44bac
commit 00d50150de
2 changed files with 14 additions and 0 deletions

View File

@ -130,7 +130,11 @@ namespace osu.Game.Online.RealtimeMultiplayer
public override async Task LeaveRoom()
{
if (!isConnected.Value)
{
// even if not connected, make sure the local room state can be cleaned up.
await base.LeaveRoom();
return;
}
if (Room == null)
return;

View File

@ -75,6 +75,16 @@ namespace osu.Game.Online.RealtimeMultiplayer
// Todo: This is temporary, until the multiplayer server returns the item id on match start or otherwise.
private int playlistItemId;
protected StatefulMultiplayerClient()
{
IsConnected.BindValueChanged(connected =>
{
// clean up local room state on server disconnect.
if (!connected.NewValue)
LeaveRoom();
});
}
/// <summary>
/// Joins the <see cref="MultiplayerRoom"/> for a given API <see cref="Room"/>.
/// </summary>