1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-09 14:34:45 +08:00

Add pool type to matchmaking room invited event (#36765)

Rebase of https://github.com/smoogipoo/osu/pull/193

Going forward, the client will have to know the type of pool being
invited to so that it can enter the appropriate screen when clicking the
notification.

Unfortunately, SignalR does not support overloading methods, or even
adding parameters to them, so this PR deprecates the
`MatchmakingRoomInvited` event and adds its replacement
`MatchmakingRoomInvitedWithParams` with a complex `invitation` parameter
that we _can_ extend in the future if required (such as potentially
adding the name of the pool).

This also prepares the notification by extracting some code to a
`Complete` method receiving said `invitation` parameter. This part of
code will be further modified to enter the correct screen:


https://github.com/smoogipoo/osu/blob/0a4018045b9d908f66c63dee65d0059d05b26e43/osu.Game/Screens/OnlinePlay/Matchmaking/Queue/QueueController.cs#L200

In particular, I have tested that new clients continue to work with the
old server (dev.ppy.sh) in quick play

|         | Old Server           | New Server  |
| ------------- |:-------------:| :-----:|
| Old Client      | 🟢  | 🟢 |
| New Client      | 🟢  | 🟢 |
This commit is contained in:
Dan Balasescu
2026-02-28 00:42:44 +09:00
committed by GitHub
Unverified
parent 2e659a79ec
commit c72b6412ea
5 changed files with 52 additions and 15 deletions
@@ -23,8 +23,19 @@ namespace osu.Game.Online.Matchmaking
/// <see cref="IMatchmakingServer.MatchmakingDeclineInvitation">declined</see>,
/// or ignored - in which case it will automatically be declined after a short timeout period.
/// </summary>
/// <remarks>
/// Provided for compatibility with older clients - can be removed 20260825.
/// </remarks>
Task MatchmakingRoomInvited();
/// <summary>
/// Signals that a match has been found and the local user is invited to it.
/// The invitation may be <see cref="IMatchmakingServer.MatchmakingAcceptInvitation">accepted</see>,
/// <see cref="IMatchmakingServer.MatchmakingDeclineInvitation">declined</see>,
/// or ignored - in which case it will automatically be declined after a short timeout period.
/// </summary>
Task MatchmakingRoomInvitedWithParams(MatchmakingRoomInvitationParams invitation);
/// <summary>
/// Signals that the matchmaking room is ready to be opened.
/// </summary>
@@ -0,0 +1,16 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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; }
}
}
@@ -123,7 +123,7 @@ namespace osu.Game.Online.Multiplayer
public event Action? MatchmakingQueueJoined;
public event Action? MatchmakingQueueLeft;
public event Action? MatchmakingRoomInvited;
public event Action<MatchmakingRoomInvitationParams>? MatchmakingRoomInvited;
public event Action<long, string>? MatchmakingRoomReady;
public event Action<MatchmakingLobbyStatus>? MatchmakingLobbyStatusChanged;
public event Action<MatchmakingQueueStatus>? 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;
}
@@ -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<MatchmakingRoomInvitationParams>(nameof(IMatchmakingClient.MatchmakingRoomInvitedWithParams), ((IMatchmakingClient)this).MatchmakingRoomInvitedWithParams);
connection.On<long, string>(nameof(IMatchmakingClient.MatchmakingRoomReady), ((IMatchmakingClient)this).MatchmakingRoomReady);
connection.On<MatchmakingLobbyStatus>(nameof(IMatchmakingClient.MatchmakingLobbyStatusChanged), ((IMatchmakingClient)this).MatchmakingLobbyStatusChanged);
connection.On<MatchmakingQueueStatus>(nameof(IMatchmakingClient.MatchmakingQueueStatusChanged), ((IMatchmakingClient)this).MatchmakingQueueStatusChanged);
@@ -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()