1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 02:02:53 +08:00

Add required server methods for kicking users

This commit is contained in:
Dean Herbert 2021-08-11 17:20:41 +09:00
parent c54a37a4ca
commit e8ad0fba75
4 changed files with 25 additions and 0 deletions

View File

@ -27,6 +27,14 @@ namespace osu.Game.Online.Multiplayer
/// <exception cref="NotJoinedRoomException">If the user is not in a room.</exception>
Task TransferHost(int userId);
/// <summary>
/// As the host, kick another user from the room.
/// </summary>
/// <param name="userId">The user to kick..</param>
/// <exception cref="NotHostException">A user other than the current host is attempting to kick a user.</exception>
/// <exception cref="NotJoinedRoomException">If the user is not in a room.</exception>
Task KickUser(int userId);
/// <summary>
/// As the host, update the settings of the currently joined room.
/// </summary>

View File

@ -293,6 +293,8 @@ namespace osu.Game.Online.Multiplayer
public abstract Task TransferHost(int userId);
public abstract Task KickUser(int userId);
public abstract Task ChangeSettings(MultiplayerRoomSettings settings);
public abstract Task ChangeState(MultiplayerUserState newState);

View File

@ -91,6 +91,14 @@ namespace osu.Game.Online.Multiplayer
return connection.InvokeAsync(nameof(IMultiplayerServer.TransferHost), userId);
}
public override Task KickUser(int userId)
{
if (!IsConnected.Value)
return Task.CompletedTask;
return connection.InvokeAsync(nameof(IMultiplayerServer.KickUser), userId);
}
public override Task ChangeSettings(MultiplayerRoomSettings settings)
{
if (!IsConnected.Value)

View File

@ -174,6 +174,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
public override Task TransferHost(int userId) => ((IMultiplayerClient)this).HostChanged(userId);
public override Task KickUser(int userId)
{
Debug.Assert(Room != null);
return ((IMultiplayerClient)this).UserLeft(Room.Users.Single(u => u.UserID == userId));
}
public override async Task ChangeSettings(MultiplayerRoomSettings settings)
{
Debug.Assert(Room != null);