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 6e30c022b05e4db0cba338a03302dfe2ee55e16d..6026e603ba293f31c0103d637370153bdc31aed7 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 e0a9150c081d6a1e36fe34292b4736d3e6607981..8210682d44320a4859d795e63dd7a8dc4154fdec 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 66c2150b27f5bc679bce8fbe4183695269c10cac..ce84d5487598a2668926f4ed76938efe5c5b05c8 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 bd3d12be5ea2da41a609d13cbe4760a35c8ebca1..d7995d1670cec1c5a14ab72eb0af20f3d9b5476c 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 fc960efbf735b5daa4b9d9b07b74fdfa29d9fb6d..6ac329255d816b5594aed944814be478921b557a 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 89ca392ffb8fa8e6a89afde3c12ec0fedf858817..b001a4f096cecb68e9e1c1324164625c1aa4448d 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 15be3bfd6c1d384069c0625ec48963f9d80c9042..4a4f57c112694e4d57c72334e8dbff8d0c164705 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 e3683c4be40edf18ad0c930bdc66e16e45902715..243b28749c6b4a379f2fda8276c2b9f399fca912 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 6fa3b6653c3e5a9e0b36c50a4ada51430a915956..f8165edcb3d80dec506449553a89c0381e89a9b3 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 cbf02293c45f5283eabe62cb01ef23c1455c0258..8cf18e19d65dfda363e9bbb8cbadc2459770f125 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 281932575510a6872619ffc00a6bd4e9deebdfa4..5b457ba97208bd0ec67461c2deb6eb3df4b20742 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