1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 16:07:24 +08:00

Merge pull request #24255 from bdach/multiplayer-disconnection-schedule-bomb

Fix several issues in multiplayer exit-on-disconnection flow
This commit is contained in:
Dean Herbert 2023-07-17 04:04:38 +09:00 committed by GitHub
commit a472fe6789
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -229,7 +229,7 @@ namespace osu.Game.Overlays.Dialog
{
// Buttons are regularly added in BDL or LoadComplete, so let's schedule to ensure
// they are ready to be pressed.
Schedule(() => Buttons.OfType<T>().FirstOrDefault()?.TriggerClick());
Scheduler.AddOnce(() => Buttons.OfType<T>().FirstOrDefault()?.TriggerClick());
}
protected override bool OnKeyDown(KeyDownEvent e)

View File

@ -17,6 +17,7 @@ using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics.Cursor;
using osu.Game.Online;
using osu.Game.Online.API;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms;
using osu.Game.Overlays;
@ -49,6 +50,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
[Resolved]
private MultiplayerClient client { get; set; }
[Resolved]
private IAPIProvider api { get; set; }
[Resolved(canBeNull: true)]
private OsuGame game { get; set; }
@ -251,10 +255,10 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
public override bool OnExiting(ScreenExitEvent e)
{
// the room may not be left immediately after a disconnection due to async flow,
// so checking the IsConnected status is also required.
if (client.Room == null || !client.IsConnected.Value)
// so checking the MultiplayerClient / IAPIAccess statuses is also required.
if (client.Room == null || !client.IsConnected.Value || api.State.Value != APIState.Online)
{
// room has not been created yet; exit immediately.
// room has not been created yet or we're offline; exit immediately.
return base.OnExiting(e);
}