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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user