RemoteCommandAttribute
Marks a class as a remote command and defines the command name used by incoming payloads. RemoteCommand<T> reads this attribute to expose the command name to the listener.
Use this attribute on classes that inherit from RemoteCommand<T>. The name must match the Command value sent by remote clients.
Usage
csharp
using System.Net.Sockets;
using AlmightyShogun.RemoteCommands;
[RemoteCommand("ping", "Replies to a health-check command.")]
public sealed class PingCommand : RemoteCommand<PingCommandData>
{
public override async Task HandleCommandAsync(PingCommandData message, NetworkStream stream)
{
await WriteResponseAsync(stream, new
{
status = "ok",
message.RequestId,
message.SentAt
});
}
}csharp
public sealed record PingCommandData(
string RequestId,
string Source,
DateTimeOffset SentAt
);Parameters
name: string
Command name expected in incoming remote command payloads.
description: string?
Optional description of what the command does.
Default: null