Class OpenClawRpcClient
JSON-RPC-over-WebSocket client for communicating with an OpenClaw gateway. Implements the OpenClaw v3 protocol: challenge-response device auth with Ed25519 signatures, typed request/response/event frames, and automatic reconnection.
public sealed class OpenClawRpcClient : IAsyncDisposable
- Inheritance
-
OpenClawRpcClient
- Implements
- Inherited Members
Constructors
OpenClawRpcClient(OpenClawConfig, ILogger<OpenClawRpcClient>)
public OpenClawRpcClient(OpenClawConfig config, ILogger<OpenClawRpcClient> logger)
Parameters
configOpenClawConfigloggerILogger<OpenClawRpcClient>
Properties
IsConnected
Whether the client is connected and authenticated.
public bool IsConnected { get; }
Property Value
Methods
ConnectAsync(CancellationToken)
Connects to the OpenClaw gateway, performs challenge-response device authentication, and starts the receive loop.
public Task ConnectAsync(CancellationToken ct = default)
Parameters
Returns
DisconnectAsync()
Gracefully disconnects from the gateway.
public Task DisconnectAsync()
Returns
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
RequestAsync(string, object?, CancellationToken)
Sends an RPC request and waits for the response.
public Task<RpcResponse> RequestAsync(string method, object? parameters = null, CancellationToken ct = default)
Parameters
methodstringparametersobjectctCancellationToken
Returns
Events
EventReceived
Raised when an event frame is received from the gateway.
public event Action<OpenClawEvent>? EventReceived