diff --git a/osu.Game/Online/Matchmaking/IMatchmakingClient.cs b/osu.Game/Online/Matchmaking/IMatchmakingClient.cs index be05e3ca0d..e44eafb390 100644 --- a/osu.Game/Online/Matchmaking/IMatchmakingClient.cs +++ b/osu.Game/Online/Matchmaking/IMatchmakingClient.cs @@ -23,8 +23,19 @@ namespace osu.Game.Online.Matchmaking /// declined, /// or ignored - in which case it will automatically be declined after a short timeout period. /// + /// + /// Provided for compatibility with older clients - can be removed 20260825. + /// Task MatchmakingRoomInvited(); + /// + /// Signals that a match has been found and the local user is invited to it. + /// The invitation may be accepted, + /// declined, + /// or ignored - in which case it will automatically be declined after a short timeout period. + /// + Task MatchmakingRoomInvitedWithParams(MatchmakingRoomInvitationParams invitation); + /// /// Signals that the matchmaking room is ready to be opened. /// diff --git a/osu.Game/Online/Matchmaking/MatchmakingRoomInvitationParams.cs b/osu.Game/Online/Matchmaking/MatchmakingRoomInvitationParams.cs new file mode 100644 index 0000000000..38b4d85734 --- /dev/null +++ b/osu.Game/Online/Matchmaking/MatchmakingRoomInvitationParams.cs @@ -0,0 +1,16 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using MessagePack; + +namespace osu.Game.Online.Matchmaking +{ + [MessagePackObject] + [Serializable] + public class MatchmakingRoomInvitationParams + { + [Key(0)] + public MatchmakingPoolType Type { get; set; } + } +} diff --git a/osu.Game/Online/Multiplayer/MultiplayerClient.cs b/osu.Game/Online/Multiplayer/MultiplayerClient.cs index 62228e60bd..b9b4419cbb 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerClient.cs @@ -123,7 +123,7 @@ namespace osu.Game.Online.Multiplayer public event Action? MatchmakingQueueJoined; public event Action? MatchmakingQueueLeft; - public event Action? MatchmakingRoomInvited; + public event Action? MatchmakingRoomInvited; public event Action? MatchmakingRoomReady; public event Action? MatchmakingLobbyStatusChanged; public event Action? MatchmakingQueueStatusChanged; @@ -1085,7 +1085,13 @@ namespace osu.Game.Online.Multiplayer Task IMatchmakingClient.MatchmakingRoomInvited() { - Scheduler.Add(() => MatchmakingRoomInvited?.Invoke()); + // Compatibility with older servers. + return ((IMatchmakingClient)this).MatchmakingRoomInvitedWithParams(new MatchmakingRoomInvitationParams { Type = MatchmakingPoolType.QuickPlay }); + } + + Task IMatchmakingClient.MatchmakingRoomInvitedWithParams(MatchmakingRoomInvitationParams invitation) + { + Scheduler.Add(() => MatchmakingRoomInvited?.Invoke(invitation)); return Task.CompletedTask; } diff --git a/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs b/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs index b36e2cf177..b23a0b3db2 100644 --- a/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs @@ -76,6 +76,7 @@ namespace osu.Game.Online.Multiplayer connection.On(nameof(IMatchmakingClient.MatchmakingQueueJoined), ((IMatchmakingClient)this).MatchmakingQueueJoined); connection.On(nameof(IMatchmakingClient.MatchmakingQueueLeft), ((IMatchmakingClient)this).MatchmakingQueueLeft); connection.On(nameof(IMatchmakingClient.MatchmakingRoomInvited), ((IMatchmakingClient)this).MatchmakingRoomInvited); + connection.On(nameof(IMatchmakingClient.MatchmakingRoomInvitedWithParams), ((IMatchmakingClient)this).MatchmakingRoomInvitedWithParams); connection.On(nameof(IMatchmakingClient.MatchmakingRoomReady), ((IMatchmakingClient)this).MatchmakingRoomReady); connection.On(nameof(IMatchmakingClient.MatchmakingLobbyStatusChanged), ((IMatchmakingClient)this).MatchmakingLobbyStatusChanged); connection.On(nameof(IMatchmakingClient.MatchmakingQueueStatusChanged), ((IMatchmakingClient)this).MatchmakingQueueStatusChanged); diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/Queue/QueueController.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/Queue/QueueController.cs index 6d23dd4eb1..9456e56bf9 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/Queue/QueueController.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/Queue/QueueController.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Sprites; using osu.Framework.Screens; using osu.Game.Graphics; +using osu.Game.Online.Matchmaking; using osu.Game.Online.Multiplayer; using osu.Game.Online.Rooms; using osu.Game.Overlays; @@ -94,15 +95,12 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Queue closeNotifications(); }); - private void onMatchmakingRoomInvited() => Scheduler.Add(() => + private void onMatchmakingRoomInvited(MatchmakingRoomInvitationParams invitation) => Scheduler.Add(() => { CurrentState.Value = ScreenQueue.MatchmakingScreenState.PendingAccept; - if (backgroundNotification != null) - { - backgroundNotification.State = ProgressNotificationState.Completed; - backgroundNotification = null; - } + backgroundNotification?.Complete(invitation); + backgroundNotification = null; }); private void onMatchmakingRoomReady(long roomId, string password) => Scheduler.Add(() => @@ -183,6 +181,17 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Queue return false; }; + CancelRequested = () => + { + client.MatchmakingLeaveQueue().FireAndForget(); + return true; + }; + + matchFoundSample = audio.Samples.Get(@"Multiplayer/Matchmaking/match-found"); + } + + public void Complete(MatchmakingRoomInvitationParams invitation) + { CompletionClickAction = () => { client.MatchmakingAcceptInvitation().FireAndForget(); @@ -194,13 +203,7 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Queue return true; }; - CancelRequested = () => - { - client.MatchmakingLeaveQueue().FireAndForget(); - return true; - }; - - matchFoundSample = audio.Samples.Get(@"Multiplayer/Matchmaking/match-found"); + State = ProgressNotificationState.Completed; } protected override Notification CreateCompletionNotification()