Make Start/Finish GameData API public

This commit is contained in:
miniduikboot committed 2024-07-29 19:57:52 +02:00
1 parent 4f7ef58b00
commit b26f451a07
2 files changed
+25 -14

No files matched your search

+23 -4
View 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);
}
+2 -10
View 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();