]> git.deb.at Git - rhonda/impostor.git/commitdiff
Make Start/Finish GameData API public
authorminiduikboot <mini@duikbo.at>
Thu, 25 Jul 2024 17:08:34 +0000 (19:08 +0200)
committerminiduikboot <mini@duikbo.at>
Mon, 29 Jul 2024 17:57:52 +0000 (19:57 +0200)
src/Impostor.Api/Games/IGame.cs
src/Impostor.Server/Net/State/Game.Outgoing.cs

index 05d6015bba168d2219077a2a626229a379b3af53..71c764a3a8cc2a4bdabc01c7926c73be2c4756e1 100644 (file)
@@ -101,22 +101,41 @@ namespace Impostor.Api.Games
         /// <returns>A <see cref="ValueTask" /> representing the asynchronous operation.</returns>
         ValueTask SendToAsync(IMessageWriter writer, int id);
 
+        /// <summary>
+        ///     Start a GameData(To) message.
+        /// </summary>
+        /// <remarks>Use with caution, recommended only for advanced developers.</remarks>
+        /// <param name="targetClientId">The client to target if needed, `null` if the message should be sent to all players.</param>
+        /// <param name="type">Message type of the message.</param>
+        /// <returns>A <see cref="IMessageWriter" /> that you can fill and send using <see cref="FinishGameDataAsync"/>.</returns>
+        IMessageWriter StartGameData(int? targetClientId = null, MessageType type = MessageType.Reliable);
+
+        /// <summary>
+        ///     Finishes GameData message and sends it to either the target or all players.
+        /// </summary>
+        /// <remarks>Use with caution, recommended only for advanced developers.</remarks>
+        /// <param name="writer">MessageWriter received from <see cref="StartGameData"/>.</param>
+        /// <param name="targetClientId">Same target ClientId passed to StartGameData.</param>
+        /// <returns>Task that sends the packet.</returns>
+        ValueTask FinishGameDataAsync(IMessageWriter writer, int? targetClientId = null);
+
         /// <summary>
         ///     Creates a MessageWriter with GameData header.
         /// </summary>
         /// <remarks>Use with caution, recommended only for advanced developers.</remarks>
         /// <param name="targetNetId">Net id of the InnerNetObject.</param>
         /// <param name="callId">Rpc id of the message.</param>
-        /// <param name="targetClientId">Client id of GameDataTo's target.</param>
+        /// <param name="targetClientId">The client to target if needed, `null` if the message should be sent to all players.</param>
         /// <param name="type">Message type of the message.</param>
         /// <returns>A <see cref="IMessageWriter" /> that you can fill with rpc data and send using <see cref="FinishRpcAsync"/>.</returns>
-        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);
 
         /// <summary>
-        /// Finishes rpc message and sends it to the target.
+        /// Finishes rpc message and sends it to either the target or all players.
         /// </summary>
+        /// <remarks>Use with caution, recommended only for advanced developers.</remarks>
         /// <param name="writer">Message writer of the rpc.</param>
-        /// <param name="targetClientId">Id of the receiving client.</param>
+        /// <param name="targetClientId">Same target client id passed to <see cref="StartRpc"/>.</param>
         /// <returns>A <see cref="ValueTask" /> representing the asynchronous operation.</returns>
         ValueTask FinishRpcAsync(IMessageWriter writer, int? targetClientId = null);
     }
index 47aa9e9f69955e180f76f34ce26c16612c1dc3a1..4c2f31fc5972e2141b1ea332945dbcbd31dac188 100644 (file)
@@ -55,11 +55,7 @@ namespace Impostor.Server.Net.State
             return FinishGameDataAsync(writer, targetClientId);
         }
 
-        /// <summary>Start a GameData(To) message.</summary>
-        /// <param name="targetClientId">The client to target if needed, `null` otherwise.</param>
-        /// <param name="type">The type of message to send, defaults to reliable.</param>
-        /// <returns>MessageWriter that should be handed back to <see cref="FinishGameDataAsync"/>.</returns>
-        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;
         }
 
-        /// <summary>Finalize and send a GameData packet.</summary>
-        /// <param name="writer">MessageWriter received from <see cref="StartGameData"/>.</param>
-        /// <param name="targetClientId">Same target ClientId passed to StartGameData.</param>
-        /// <returns>Task that sends the packet.</returns>
-        private ValueTask FinishGameDataAsync(IMessageWriter writer, int? targetClientId = null)
+        public ValueTask FinishGameDataAsync(IMessageWriter writer, int? targetClientId = null)
         {
             writer.EndMessage();