From: miniduikboot Date: Thu, 25 Jul 2024 17:08:34 +0000 (+0200) Subject: Make Start/Finish GameData API public X-Git-Tag: v1.10.0~15 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=b26f451a07b002fba484a5435472c16345db7065;p=rhonda%2Fimpostor.git Make Start/Finish GameData API public --- diff --git a/src/Impostor.Api/Games/IGame.cs b/src/Impostor.Api/Games/IGame.cs index 05d6015..71c764a 100644 --- a/src/Impostor.Api/Games/IGame.cs +++ b/src/Impostor.Api/Games/IGame.cs @@ -101,22 +101,41 @@ namespace Impostor.Api.Games /// A representing the asynchronous operation. ValueTask SendToAsync(IMessageWriter writer, int id); + /// + /// Start a GameData(To) message. + /// + /// Use with caution, recommended only for advanced developers. + /// The client to target if needed, `null` if the message should be sent to all players. + /// Message type of the message. + /// A that you can fill and send using . + IMessageWriter StartGameData(int? targetClientId = null, MessageType type = MessageType.Reliable); + + /// + /// Finishes GameData message and sends it to either the target or all players. + /// + /// Use with caution, recommended only for advanced developers. + /// MessageWriter received from . + /// Same target ClientId passed to StartGameData. + /// Task that sends the packet. + ValueTask FinishGameDataAsync(IMessageWriter writer, int? targetClientId = null); + /// /// Creates a MessageWriter with GameData header. /// /// Use with caution, recommended only for advanced developers. /// Net id of the InnerNetObject. /// Rpc id of the message. - /// Client id of GameDataTo's target. + /// The client to target if needed, `null` if the message should be sent to all players. /// Message type of the message. /// A that you can fill with rpc data and send using . - IMessageWriter StartRpc(uint targetNetId, RpcCalls callId, int? targetClientId, MessageType type = MessageType.Reliable); + IMessageWriter StartRpc(uint targetNetId, RpcCalls callId, int? targetClientId = null, MessageType type = MessageType.Reliable); /// - /// Finishes rpc message and sends it to the target. + /// Finishes rpc message and sends it to either the target or all players. /// + /// Use with caution, recommended only for advanced developers. /// Message writer of the rpc. - /// Id of the receiving client. + /// Same target client id passed to . /// A representing the asynchronous operation. ValueTask FinishRpcAsync(IMessageWriter writer, int? targetClientId = null); } diff --git a/src/Impostor.Server/Net/State/Game.Outgoing.cs b/src/Impostor.Server/Net/State/Game.Outgoing.cs index 47aa9e9..4c2f31f 100644 --- a/src/Impostor.Server/Net/State/Game.Outgoing.cs +++ b/src/Impostor.Server/Net/State/Game.Outgoing.cs @@ -55,11 +55,7 @@ namespace Impostor.Server.Net.State return FinishGameDataAsync(writer, targetClientId); } - /// Start a GameData(To) message. - /// The client to target if needed, `null` otherwise. - /// The type of message to send, defaults to reliable. - /// MessageWriter that should be handed back to . - private IMessageWriter StartGameData(int? targetClientId = null, MessageType type = MessageType.Reliable) + public IMessageWriter StartGameData(int? targetClientId = null, MessageType type = MessageType.Reliable) { var writer = MessageWriter.Get(type); @@ -78,11 +74,7 @@ namespace Impostor.Server.Net.State return writer; } - /// Finalize and send a GameData packet. - /// MessageWriter received from . - /// Same target ClientId passed to StartGameData. - /// Task that sends the packet. - private ValueTask FinishGameDataAsync(IMessageWriter writer, int? targetClientId = null) + public ValueTask FinishGameDataAsync(IMessageWriter writer, int? targetClientId = null) { writer.EndMessage();