mirror of
https://github.com/ppy/osu
synced 2024-12-29 10:22:43 +00: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:
commit
a472fe6789
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user