-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #265 from smoogipoo/room-management-lio
Add support for creating, joining, and parting osu!web rooms via interop
- Loading branch information
Showing
11 changed files
with
353 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// 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.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Moq; | ||
using osu.Game.Online.Multiplayer; | ||
using Xunit; | ||
|
||
namespace osu.Server.Spectator.Tests.Multiplayer | ||
{ | ||
public class RoomInteropTest : MultiplayerTest | ||
{ | ||
[Fact] | ||
public async Task CreateRoom() | ||
{ | ||
LegacyIO.Setup(io => io.CreateRoomAsync(It.IsAny<int>(), It.IsAny<MultiplayerRoom>())) | ||
.ReturnsAsync(() => ROOM_ID); | ||
|
||
await Hub.CreateRoom(new MultiplayerRoom(0)); | ||
LegacyIO.Verify(io => io.CreateRoomAsync(USER_ID, It.IsAny<MultiplayerRoom>()), Times.Once); | ||
LegacyIO.Verify(io => io.AddUserToRoomAsync(ROOM_ID, USER_ID), Times.Once); | ||
|
||
using (var usage = await Hub.GetRoom(ROOM_ID)) | ||
{ | ||
Assert.NotNull(usage.Item); | ||
Assert.Equal(USER_ID, usage.Item.Users.Single().UserID); | ||
} | ||
} | ||
|
||
[Fact] | ||
public async Task LeaveRoom() | ||
{ | ||
await Hub.JoinRoom(ROOM_ID); | ||
LegacyIO.Verify(io => io.RemoveUserFromRoomAsync(ROOM_ID, USER_ID), Times.Never); | ||
|
||
await Hub.LeaveRoom(); | ||
LegacyIO.Verify(io => io.RemoveUserFromRoomAsync(ROOM_ID, USER_ID), Times.Once); | ||
|
||
await Assert.ThrowsAsync<KeyNotFoundException>(() => Hub.GetRoom(ROOM_ID)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 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.Threading.Tasks; | ||
using osu.Game.Online.Multiplayer; | ||
|
||
namespace osu.Server.Spectator.Services | ||
{ | ||
public interface ILegacyIO | ||
{ | ||
/// <summary> | ||
/// Creates an osu!web room. | ||
/// </summary> | ||
/// <remarks> | ||
/// This does not join the creating user to the room. A subsequent call to <see cref="AddUserToRoomAsync"/> should be made if required. | ||
/// </remarks> | ||
/// <param name="hostUserId">The ID of the user that wants to create the room.</param> | ||
/// <param name="room">The room.</param> | ||
/// <returns>The room's ID.</returns> | ||
Task<long> CreateRoomAsync(int hostUserId, MultiplayerRoom room); | ||
|
||
/// <summary> | ||
/// Adds a user to an osu!web room. | ||
/// </summary> | ||
/// <remarks> | ||
/// This performs setup tasks like adding the user to the relevant chat channel. | ||
/// </remarks> | ||
/// <param name="roomId">The ID of the room to join.</param> | ||
/// <param name="userId">The ID of the user wanting to join the room.</param> | ||
Task AddUserToRoomAsync(long roomId, int userId); | ||
|
||
/// <summary> | ||
/// Parts an osu!web room. | ||
/// </summary> | ||
/// <remarks> | ||
/// This performs setup tasks like removing the user from any relevant chat channels. | ||
/// </remarks> | ||
/// <param name="roomId">The ID of the room to part.</param> | ||
/// <param name="userId">The ID of the user wanting to part the room.</param> | ||
Task RemoveUserFromRoomAsync(long roomId, int userId); | ||
} | ||
} |
Oops, something went wrong.