M src/Core/NosSmooth.Comms.Abstractions/Messages/CommandMessage.cs => src/Core/NosSmooth.Comms.Abstractions/Messages/CommandMessage.cs +4 -0
@@ 8,4 8,8 @@ using NosSmooth.Core.Commands;
namespace NosSmooth.Comms.Data.Messages;
+/// <summary>
+/// Send a command.
+/// </summary>
+/// <param name="Command">The command to send.</param>
public record CommandMessage(ICommand Command);=
\ No newline at end of file
M src/Core/NosSmooth.Comms.Abstractions/Messages/MessageWrapper.cs => src/Core/NosSmooth.Comms.Abstractions/Messages/MessageWrapper.cs +7 -0
@@ 6,4 6,11 @@
namespace NosSmooth.Comms.Data.Messages;
+/// <summary>
+/// A wrapper, each message is sent wrapped.
+/// </summary>
+/// <param name="ProtocolVersion">The version of protocol used.</param>
+/// <param name="MessageId">The id of the message, used for connecting responses to messages.</param>
+/// <param name="Data">The message itself.</param>
+/// <typeparam name="TMessage">The type of the message.</typeparam>
public record MessageWrapper<TMessage>(long ProtocolVersion, long MessageId, TMessage Data);=
\ No newline at end of file
M src/Core/NosSmooth.Comms.Abstractions/Messages/PacketMessage.cs => src/Core/NosSmooth.Comms.Abstractions/Messages/PacketMessage.cs +8 -0
@@ 9,4 9,12 @@ using NosSmooth.PacketSerializer.Abstractions.Attributes;
namespace NosSmooth.Comms.Data.Messages;
+/// <summary>
+/// A message containing deserialized packet.
+/// </summary>
+/// <remarks>
+/// May be used for sending or receiving a packet.
+/// </remarks>
+/// <param name="Source">The source the packet comes from.</param>
+/// <param name="Packet">The deserialized packet.</param>
public record PacketMessage(PacketSource Source, IPacket Packet);=
\ No newline at end of file
M src/Core/NosSmooth.Comms.Abstractions/Messages/RawPacketMessage.cs => src/Core/NosSmooth.Comms.Abstractions/Messages/RawPacketMessage.cs +8 -0
@@ 8,4 8,12 @@ using NosSmooth.PacketSerializer.Abstractions.Attributes;
namespace NosSmooth.Comms.Data.Messages;
+/// <summary>
+/// A message containing serialized packet.
+/// </summary>
+/// <remarks>
+/// May be used for sending or receiving a packet.
+/// </remarks>
+/// <param name="Source">The source the packet comes from.</param>
+/// <param name="Packet">The packet string.</param>
public record RawPacketMessage(PacketSource Source, string Packet);=
\ No newline at end of file
M src/Core/NosSmooth.Comms.Abstractions/Messages/ResponseResult.cs => src/Core/NosSmooth.Comms.Abstractions/Messages/ResponseResult.cs +6 -0
@@ 8,4 8,10 @@ using Remora.Results;
namespace NosSmooth.Comms.Data.Messages;
+/// <summary>
+/// A response to a received message,
+/// sent from server to client.
+/// </summary>
+/// <param name="MessageId">The id of the message this response is for.</param>
+/// <param name="Result">The result.</param>
public record ResponseResult(long MessageId, Result Result);=
\ No newline at end of file
M src/Core/NosSmooth.Comms.Core/MessageHandler.cs => src/Core/NosSmooth.Comms.Core/MessageHandler.cs +1 -6
@@ 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}");
}
M src/Local/NosSmooth.Comms.Inject/CallbackConfig.cs => src/Local/NosSmooth.Comms.Inject/CallbackConfig.cs +5 -0
@@ 6,4 6,9 @@
namespace NosSmooth.Comms.Inject;
+/// <summary>
+/// A config of a client setting what messages to send.
+/// </summary>
+/// <param name="SendRawPackets">Whether to send raw serialized packets to client upon receive/send.</param>
+/// <param name="SendDeserializedPackets">Whether to send deserialized packets to client upon receive/send.</param>
public record CallbackConfig(bool SendRawPackets, bool SendDeserializedPackets);=
\ No newline at end of file
M src/Local/NosSmooth.Comms.Inject/Messages/ConsoleMessage.cs => src/Local/NosSmooth.Comms.Inject/Messages/ConsoleMessage.cs +4 -0
@@ 6,4 6,8 @@
namespace NosSmooth.Comms.Inject.Messages;
+/// <summary>
+/// A message used for opening or closing console.
+/// </summary>
+/// <param name="Open">Whether to open the console.</param>
public record ConsoleMessage(bool Open);=
\ No newline at end of file
M src/Local/NosSmooth.Comms.Inject/Messages/FocusMessage.cs => src/Local/NosSmooth.Comms.Inject/Messages/FocusMessage.cs +4 -0
@@ 6,4 6,8 @@
namespace NosSmooth.Comms.Inject.Messages;
+/// <summary>
+/// Focus the given entity.
+/// </summary>
+/// <param name="EntityId">The id of the entity, unfocus if null.</param>
public record FocusMessage(long? EntityId);=
\ No newline at end of file
M src/Local/NosSmooth.Comms.Inject/Messages/FollowMessage.cs => src/Local/NosSmooth.Comms.Inject/Messages/FollowMessage.cs +4 -0
@@ 6,4 6,8 @@
namespace NosSmooth.Comms.Inject.Messages;
+/// <summary>
+/// Follow the given entity, unfollow if null.
+/// </summary>
+/// <param name="EntityId">The id of the entity, unfollow if null.</param>
public record FollowMessage(long? EntityId);=
\ No newline at end of file
M src/Local/NosSmooth.Comms.Local/Comms.cs => src/Local/NosSmooth.Comms.Local/Comms.cs +6 -0
@@ 10,4 10,10 @@ using NosSmooth.Core.Client;
namespace NosSmooth.Comms.Local;
+/// <summary>
+/// A group describing a connection client.
+/// </summary>
+/// <param name="NosTaleProcess">The process the connection is established with.</param>
+/// <param name="Connection">The connection handler wrapping the client connection.</param>
+/// <param name="Client">The nostale client for handling and sending packets, commands.</param>
public record Comms(Process NosTaleProcess, ConnectionHandler Connection, INostaleClient Client);=
\ No newline at end of file