1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 14:57:52 +08:00

Add flow for sending match ruleset specific messages to the server

This commit is contained in:
Dean Herbert 2021-07-21 19:13:56 +09:00
parent e8338f2711
commit 9d1e95caf0
6 changed files with 48 additions and 0 deletions

View File

@ -55,6 +55,12 @@ namespace osu.Game.Online.Multiplayer
/// <param name="newMods">The proposed new mods, excluding any required by the room itself.</param>
Task ChangeUserMods(IEnumerable<APIMod> newMods);
/// <summary>
/// Send a match ruleset specific request.
/// </summary>
/// <param name="request">The request to send.</param>
Task SendMatchRulesetRequest(MatchRulesetUserRequest request);
/// <summary>
/// As the host of a room, start the match.
/// </summary>

View File

@ -0,0 +1,17 @@
// 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.Multiplayer
{
/// <summary>
/// A request from a user to perform an action specific to the current match ruleset.
/// </summary>
[Serializable]
[MessagePackObject]
public abstract class MatchRulesetUserRequest
{
}
}

View File

@ -0,0 +1,13 @@
// 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 MessagePack;
namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs
{
public class ChangeTeamRequest : MatchRulesetUserRequest
{
[Key(0)]
public int TeamID { get; set; }
}
}

View File

@ -293,6 +293,8 @@ namespace osu.Game.Online.Multiplayer
public abstract Task ChangeUserMods(IEnumerable<APIMod> newMods);
public abstract Task SendMatchRulesetRequest(MatchRulesetUserRequest request);
public abstract Task StartMatch();
Task IMultiplayerClient.RoomStateChanged(MultiplayerRoomState state)

View File

@ -118,6 +118,14 @@ namespace osu.Game.Online.Multiplayer
return connection.InvokeAsync(nameof(IMultiplayerServer.ChangeUserMods), newMods);
}
public override Task SendMatchRulesetRequest(MatchRulesetUserRequest request)
{
if (!IsConnected.Value)
return Task.CompletedTask;
return connection.InvokeAsync(nameof(IMultiplayerServer.SendMatchRulesetRequest), request);
}
public override Task StartMatch()
{
if (!IsConnected.Value)

View File

@ -192,6 +192,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
return Task.CompletedTask;
}
public override Task SendMatchRulesetRequest(MatchRulesetUserRequest request) => Task.CompletedTask;
public override Task StartMatch()
{
Debug.Assert(Room != null);