From 11a7057289b20a195bd1be91e1a11681d2f29eb2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Dec 2020 17:41:56 +0900 Subject: [PATCH] Add notification flow for user state changes in room --- .../RealtimeMultiplayer/IMultiplayerServer.cs | 7 +++++++ .../RealtimeMultiplayer/ISpectatorClient.cs | 7 +++++++ .../RealtimeMultiplayer/InvalidStateChange.cs | 15 +++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 osu.Game/Online/RealtimeMultiplayer/InvalidStateChange.cs diff --git a/osu.Game/Online/RealtimeMultiplayer/IMultiplayerServer.cs b/osu.Game/Online/RealtimeMultiplayer/IMultiplayerServer.cs index 44d7ecc2e9..ad4aa5d2c2 100644 --- a/osu.Game/Online/RealtimeMultiplayer/IMultiplayerServer.cs +++ b/osu.Game/Online/RealtimeMultiplayer/IMultiplayerServer.cs @@ -30,5 +30,12 @@ namespace osu.Game.Online.RealtimeMultiplayer /// /// The new settings to apply. Task ChangeSettings(MultiplayerRoomSettings settings); + + /// + /// Change the local user state in the currently joined room. + /// + /// The proposed new state. + /// If the state change requested is not valid, given the previous state or room state. + Task ChangeState(MultiplayerUserState newState); } } diff --git a/osu.Game/Online/RealtimeMultiplayer/ISpectatorClient.cs b/osu.Game/Online/RealtimeMultiplayer/ISpectatorClient.cs index f3dff0de86..fa06652474 100644 --- a/osu.Game/Online/RealtimeMultiplayer/ISpectatorClient.cs +++ b/osu.Game/Online/RealtimeMultiplayer/ISpectatorClient.cs @@ -39,5 +39,12 @@ namespace osu.Game.Online.RealtimeMultiplayer /// /// The updated room settings. Task SettingsChanged(MultiplayerRoomSettings newSettings); + + /// + /// Signals that a user in this room changed their state. + /// + /// The ID of the user performing a state change. + /// The new state of the user. + Task UserStateChanged(long userId, MultiplayerUserState state); } } diff --git a/osu.Game/Online/RealtimeMultiplayer/InvalidStateChange.cs b/osu.Game/Online/RealtimeMultiplayer/InvalidStateChange.cs new file mode 100644 index 0000000000..d1016e95cb --- /dev/null +++ b/osu.Game/Online/RealtimeMultiplayer/InvalidStateChange.cs @@ -0,0 +1,15 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; + +namespace osu.Game.Online.RealtimeMultiplayer +{ + public class InvalidStateChange : Exception + { + public InvalidStateChange(MultiplayerUserState oldState, MultiplayerUserState newState) + : base($"Cannot change from {oldState} to {newState}") + { + } + } +}