From 190a8692e2acbadd240b755dac9b48c7f77d96c1 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Tue, 14 Feb 2023 22:05:04 +0100 Subject: [PATCH] docs: add missing documentation --- .../Messages/CommandMessage.cs | 4 ++++ .../Messages/MessageWrapper.cs | 7 +++++++ .../Messages/PacketMessage.cs | 8 ++++++++ .../Messages/RawPacketMessage.cs | 8 ++++++++ .../Messages/ResponseResult.cs | 6 ++++++ src/Core/NosSmooth.Comms.Core/MessageHandler.cs | 7 +------ src/Local/NosSmooth.Comms.Inject/CallbackConfig.cs | 5 +++++ .../NosSmooth.Comms.Inject/Messages/ConsoleMessage.cs | 4 ++++ src/Local/NosSmooth.Comms.Inject/Messages/FocusMessage.cs | 4 ++++ .../NosSmooth.Comms.Inject/Messages/FollowMessage.cs | 4 ++++ src/Local/NosSmooth.Comms.Local/Comms.cs | 6 ++++++ 11 files changed, 57 insertions(+), 6 deletions(-) diff --git a/src/Core/NosSmooth.Comms.Abstractions/Messages/CommandMessage.cs b/src/Core/NosSmooth.Comms.Abstractions/Messages/CommandMessage.cs index 6e30c02..6026e60 100644 --- a/src/Core/NosSmooth.Comms.Abstractions/Messages/CommandMessage.cs +++ b/src/Core/NosSmooth.Comms.Abstractions/Messages/CommandMessage.cs @@ -8,4 +8,8 @@ using NosSmooth.Core.Commands; namespace NosSmooth.Comms.Data.Messages; +/// +/// Send a command. +/// +/// The command to send. public record CommandMessage(ICommand Command); \ No newline at end of file diff --git a/src/Core/NosSmooth.Comms.Abstractions/Messages/MessageWrapper.cs b/src/Core/NosSmooth.Comms.Abstractions/Messages/MessageWrapper.cs index e0a9150..8210682 100644 --- a/src/Core/NosSmooth.Comms.Abstractions/Messages/MessageWrapper.cs +++ b/src/Core/NosSmooth.Comms.Abstractions/Messages/MessageWrapper.cs @@ -6,4 +6,11 @@ namespace NosSmooth.Comms.Data.Messages; +/// +/// A wrapper, each message is sent wrapped. +/// +/// The version of protocol used. +/// The id of the message, used for connecting responses to messages. +/// The message itself. +/// The type of the message. public record MessageWrapper(long ProtocolVersion, long MessageId, TMessage Data); \ No newline at end of file diff --git a/src/Core/NosSmooth.Comms.Abstractions/Messages/PacketMessage.cs b/src/Core/NosSmooth.Comms.Abstractions/Messages/PacketMessage.cs index 66c2150..ce84d54 100644 --- a/src/Core/NosSmooth.Comms.Abstractions/Messages/PacketMessage.cs +++ b/src/Core/NosSmooth.Comms.Abstractions/Messages/PacketMessage.cs @@ -9,4 +9,12 @@ using NosSmooth.PacketSerializer.Abstractions.Attributes; namespace NosSmooth.Comms.Data.Messages; +/// +/// A message containing deserialized packet. +/// +/// +/// May be used for sending or receiving a packet. +/// +/// The source the packet comes from. +/// The deserialized packet. public record PacketMessage(PacketSource Source, IPacket Packet); \ No newline at end of file diff --git a/src/Core/NosSmooth.Comms.Abstractions/Messages/RawPacketMessage.cs b/src/Core/NosSmooth.Comms.Abstractions/Messages/RawPacketMessage.cs index bd3d12b..d7995d1 100644 --- a/src/Core/NosSmooth.Comms.Abstractions/Messages/RawPacketMessage.cs +++ b/src/Core/NosSmooth.Comms.Abstractions/Messages/RawPacketMessage.cs @@ -8,4 +8,12 @@ using NosSmooth.PacketSerializer.Abstractions.Attributes; namespace NosSmooth.Comms.Data.Messages; +/// +/// A message containing serialized packet. +/// +/// +/// May be used for sending or receiving a packet. +/// +/// The source the packet comes from. +/// The packet string. public record RawPacketMessage(PacketSource Source, string Packet); \ No newline at end of file diff --git a/src/Core/NosSmooth.Comms.Abstractions/Messages/ResponseResult.cs b/src/Core/NosSmooth.Comms.Abstractions/Messages/ResponseResult.cs index fc960ef..6ac3292 100644 --- a/src/Core/NosSmooth.Comms.Abstractions/Messages/ResponseResult.cs +++ b/src/Core/NosSmooth.Comms.Abstractions/Messages/ResponseResult.cs @@ -8,4 +8,10 @@ using Remora.Results; namespace NosSmooth.Comms.Data.Messages; +/// +/// A response to a received message, +/// sent from server to client. +/// +/// The id of the message this response is for. +/// The result. public record ResponseResult(long MessageId, Result Result); \ No newline at end of file diff --git a/src/Core/NosSmooth.Comms.Core/MessageHandler.cs b/src/Core/NosSmooth.Comms.Core/MessageHandler.cs index 89ca392..b001a4f 100644 --- a/src/Core/NosSmooth.Comms.Core/MessageHandler.cs +++ b/src/Core/NosSmooth.Comms.Core/MessageHandler.cs @@ -48,12 +48,7 @@ public class MessageHandler (ConnectionHandler connection, object wrappedMessage, CancellationToken ct) { var wrappedType = wrappedMessage.GetType(); - if (!wrappedType.IsGenericType) - { - return new GenericError($"Message type is not MessageWrapper<>, but {wrappedType.FullName}"); - } - - if (wrappedType.GetGenericTypeDefinition() != typeof(MessageWrapper<>)) + if (!wrappedType.IsGenericType || wrappedType.GetGenericTypeDefinition() != typeof(MessageWrapper<>)) { return new GenericError($"Message type is not MessageWrapper<>, but {wrappedType.FullName}"); } diff --git a/src/Local/NosSmooth.Comms.Inject/CallbackConfig.cs b/src/Local/NosSmooth.Comms.Inject/CallbackConfig.cs index 15be3bf..4a4f57c 100644 --- a/src/Local/NosSmooth.Comms.Inject/CallbackConfig.cs +++ b/src/Local/NosSmooth.Comms.Inject/CallbackConfig.cs @@ -6,4 +6,9 @@ namespace NosSmooth.Comms.Inject; +/// +/// A config of a client setting what messages to send. +/// +/// Whether to send raw serialized packets to client upon receive/send. +/// Whether to send deserialized packets to client upon receive/send. public record CallbackConfig(bool SendRawPackets, bool SendDeserializedPackets); \ No newline at end of file diff --git a/src/Local/NosSmooth.Comms.Inject/Messages/ConsoleMessage.cs b/src/Local/NosSmooth.Comms.Inject/Messages/ConsoleMessage.cs index e3683c4..243b287 100644 --- a/src/Local/NosSmooth.Comms.Inject/Messages/ConsoleMessage.cs +++ b/src/Local/NosSmooth.Comms.Inject/Messages/ConsoleMessage.cs @@ -6,4 +6,8 @@ namespace NosSmooth.Comms.Inject.Messages; +/// +/// A message used for opening or closing console. +/// +/// Whether to open the console. public record ConsoleMessage(bool Open); \ No newline at end of file diff --git a/src/Local/NosSmooth.Comms.Inject/Messages/FocusMessage.cs b/src/Local/NosSmooth.Comms.Inject/Messages/FocusMessage.cs index 6fa3b66..f8165ed 100644 --- a/src/Local/NosSmooth.Comms.Inject/Messages/FocusMessage.cs +++ b/src/Local/NosSmooth.Comms.Inject/Messages/FocusMessage.cs @@ -6,4 +6,8 @@ namespace NosSmooth.Comms.Inject.Messages; +/// +/// Focus the given entity. +/// +/// The id of the entity, unfocus if null. public record FocusMessage(long? EntityId); \ No newline at end of file diff --git a/src/Local/NosSmooth.Comms.Inject/Messages/FollowMessage.cs b/src/Local/NosSmooth.Comms.Inject/Messages/FollowMessage.cs index cbf0229..8cf18e1 100644 --- a/src/Local/NosSmooth.Comms.Inject/Messages/FollowMessage.cs +++ b/src/Local/NosSmooth.Comms.Inject/Messages/FollowMessage.cs @@ -6,4 +6,8 @@ namespace NosSmooth.Comms.Inject.Messages; +/// +/// Follow the given entity, unfollow if null. +/// +/// The id of the entity, unfollow if null. public record FollowMessage(long? EntityId); \ No newline at end of file diff --git a/src/Local/NosSmooth.Comms.Local/Comms.cs b/src/Local/NosSmooth.Comms.Local/Comms.cs index 2819325..5b457ba 100644 --- a/src/Local/NosSmooth.Comms.Local/Comms.cs +++ b/src/Local/NosSmooth.Comms.Local/Comms.cs @@ -10,4 +10,10 @@ using NosSmooth.Core.Client; namespace NosSmooth.Comms.Local; +/// +/// A group describing a connection client. +/// +/// The process the connection is established with. +/// The connection handler wrapping the client connection. +/// The nostale client for handling and sending packets, commands. public record Comms(Process NosTaleProcess, ConnectionHandler Connection, INostaleClient Client); \ No newline at end of file -- 2.48.1