Skip to content

RemoteCommandAttribute ​

Marks a class as a remote command and names it. Required on every class inheriting RemoteCommand<T>, and the name must match the Command value sent by clients.

Usage ​

csharp
using AlmightyShogun.RemoteCommands;

[RemoteCommand("ping", "Replies to a health-check command.")]
public sealed class PingCommand : RemoteCommand<PingCommandData>
{
    public override Task HandleCommandAsync(
        PingCommandData message,
        ICommandResponse response,
        CancellationToken cancellationToken
    ) => response.WriteAsync(new
    {
        status = "ok",
        message.RequestId
    }, cancellationToken);
}
csharp
public sealed record PingCommandData(
    string RequestId,
    DateTimeOffset SentAt
);

Parameters

name: string
Command name expected in incoming remote command payloads.

description: string?
Optional description of what the command does.
Default: null

Type signature ​

csharp
public RemoteCommandAttribute(
    string name,
    string? description = null
);

All packages are released under the MIT License.