1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-04 02:53:38 +08:00

Merge pull request #35971 from smoogipoo/fix-mp-screen-leave

Forcefully leave room on multiplayer exit
This commit is contained in:
Dean Herbert
2025-12-12 17:06:20 +09:00
committed by GitHub
Unverified
3 changed files with 9 additions and 4 deletions
@@ -16,7 +16,6 @@ namespace osu.Game.Online.Multiplayer
/// <summary>
/// Request to leave the currently joined room.
/// </summary>
/// <exception cref="NotJoinedRoomException">If the user is not in a room.</exception>
Task LeaveRoom();
/// <summary>
@@ -319,9 +319,6 @@ namespace osu.Game.Online.Multiplayer
public Task LeaveRoom()
{
if (Room == null)
return Task.CompletedTask;
// The join may have not completed yet, so certain tasks that either update the room or reference the room should be cancelled.
// This includes the setting of Room itself along with the initial update of the room settings on join.
joinCancellationSource?.Cancel();
@@ -90,6 +90,15 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
client.ChangeState(MultiplayerUserState.Idle).FireAndForget();
}
public override bool OnExiting(ScreenExitEvent e)
{
if (base.OnExiting(e))
return true;
client.LeaveRoom().FireAndForget();
return false;
}
protected override string ScreenTitle => "Multiplayer";
protected override LoungeSubScreen CreateLounge() => new MultiplayerLoungeSubScreen();