-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for creating, joining, and parting osu!web rooms via interop #265
Open
smoogipoo
wants to merge
11
commits into
ppy:master
Choose a base branch
from
smoogipoo:room-management-lio
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4278883
Add LIO service helper
smoogipoo 9d51555
Add support for creating rooms via LIO
smoogipoo 1ee9712
Add support for joining/parting rooms via LIO
smoogipoo b5b5a9f
Adjust exception handling for hub usage
smoogipoo 76bd084
Refactorings and cleanups
smoogipoo 39bdada
Add "Async" suffix
smoogipoo 5288875
Add env vars to readme
smoogipoo 977d127
Clean up hashing
smoogipoo 8e46fab
Fix tests
smoogipoo 32a591f
Add some basic interop tests
smoogipoo 9b33f05
Don't use switch expression
smoogipoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <[email protected]>. 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.JoinRoomAsync(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.PartRoomAsync(ROOM_ID, USER_ID), Times.Never); | ||
|
||
await Hub.LeaveRoom(); | ||
LegacyIO.Verify(io => io.PartRoomAsync(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,33 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. 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> | ||
/// <param name="userId">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 userId, MultiplayerRoom room); | ||
|
||
/// <summary> | ||
/// Joins an osu!web Room. | ||
/// </summary> | ||
/// <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 JoinRoomAsync(long roomId, int userId); | ||
|
||
/// <summary> | ||
/// Parts an osu!web Room. | ||
/// </summary> | ||
/// <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 PartRoomAsync(long roomId, int userId); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meaningless change because the base implementation is empty. I just thought I'd make this consistent with other implementations, seeing as
leaveRoom
can throw an exception.