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() public override async Task LeaveRoom()
{ {
if (!isConnected.Value) if (!isConnected.Value)
{
// even if not connected, make sure the local room state can be cleaned up.
await base.LeaveRoom();
return; return;
}
if (Room == null) if (Room == null)
return; 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. // Todo: This is temporary, until the multiplayer server returns the item id on match start or otherwise.
private int playlistItemId; private int playlistItemId;
protected StatefulMultiplayerClient()
{
IsConnected.BindValueChanged(connected =>
{
// clean up local room state on server disconnect.
if (!connected.NewValue)
LeaveRoom();
});
}
/// <summary> /// <summary>
/// Joins the <see cref="MultiplayerRoom"/> for a given API <see cref="Room"/>. /// Joins the <see cref="MultiplayerRoom"/> for a given API <see cref="Room"/>.
/// </summary> /// </summary>