1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

Add Invited task to multiplayer client

This commit is contained in:
Marvin Schürz 2023-10-02 22:53:28 +02:00
parent d19cdbdefb
commit 574dc67a9e
4 changed files with 28 additions and 0 deletions

View File

@ -42,6 +42,13 @@ namespace osu.Game.Online.Multiplayer
/// <param name="user">The user.</param>
Task UserKicked(MultiplayerRoomUser user);
/// <summary>
/// Signals that a user has been invited into a multiplayer room.
/// </summary>
/// <param name="invitedBy">Id of user that invited the player.</param>
/// <param name="room">The room the user got invited to.</param>
Task Invited(int invitedBy, MultiplayerRoom room);
/// <summary>
/// Signal that the host of the room has changed.
/// </summary>

View File

@ -442,6 +442,21 @@ namespace osu.Game.Online.Multiplayer
return handleUserLeft(user, UserKicked);
}
async Task IMultiplayerClient.Invited(int invitedBy, MultiplayerRoom room)
{
var user = await userLookupCache.GetUserAsync(invitedBy).ConfigureAwait(false);
if (user == null) return;
Scheduler.Add(() =>
{
PostNotification?.Invoke(new SimpleNotification
{
Text = "You got invited into a multiplayer match by " + user.Username + "!",
});
});
}
private void addUserToAPIRoom(MultiplayerRoomUser user)
{
Debug.Assert(APIRoom != null);

View File

@ -50,6 +50,7 @@ namespace osu.Game.Online.Multiplayer
connection.On<MultiplayerRoomUser>(nameof(IMultiplayerClient.UserJoined), ((IMultiplayerClient)this).UserJoined);
connection.On<MultiplayerRoomUser>(nameof(IMultiplayerClient.UserLeft), ((IMultiplayerClient)this).UserLeft);
connection.On<MultiplayerRoomUser>(nameof(IMultiplayerClient.UserKicked), ((IMultiplayerClient)this).UserKicked);
connection.On<int, MultiplayerRoom>(nameof(IMultiplayerClient.Invited), ((IMultiplayerClient)this).Invited);
connection.On<int>(nameof(IMultiplayerClient.HostChanged), ((IMultiplayerClient)this).HostChanged);
connection.On<MultiplayerRoomSettings>(nameof(IMultiplayerClient.SettingsChanged), ((IMultiplayerClient)this).SettingsChanged);
connection.On<int, MultiplayerUserState>(nameof(IMultiplayerClient.UserStateChanged), ((IMultiplayerClient)this).UserStateChanged);

View File

@ -263,6 +263,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
return Task.CompletedTask;
}
public override Task InvitePlayer(int userId)
{
return Task.CompletedTask;
}
public override Task TransferHost(int userId)
{
userId = clone(userId);