Class OpenClawBridgeChannel
Bridges JD.AI gateway to an OpenClaw instance via WebSocket JSON-RPC.
Implements IChannel to appear as a regular channel in the JD.AI gateway.
Messages sent to this channel are forwarded to OpenClaw via chat.send;
messages from OpenClaw are surfaced as inbound channel messages via chat events.
public sealed class OpenClawBridgeChannel : IChannel, IAsyncDisposable
- Inheritance
-
OpenClawBridgeChannel
- Implements
- Inherited Members
Constructors
OpenClawBridgeChannel(OpenClawRpcClient, ILogger<OpenClawBridgeChannel>, OpenClawConfig)
public OpenClawBridgeChannel(OpenClawRpcClient rpc, ILogger<OpenClawBridgeChannel> logger, OpenClawConfig config)
Parameters
rpcOpenClawRpcClientloggerILogger<OpenClawBridgeChannel>configOpenClawConfig
Properties
ChannelType
Unique channel type identifier (e.g., "discord", "signal", "web").
public string ChannelType { get; }
Property Value
DisplayName
Display name for this channel instance.
public string DisplayName { get; }
Property Value
IsConnected
Whether the channel is currently connected and healthy.
public bool IsConnected { get; }
Property Value
RpcClient
The underlying RPC client for direct event subscription.
public OpenClawRpcClient RpcClient { get; }
Property Value
Methods
AbortSessionAsync(string, CancellationToken)
Aborts the currently running agent for an OpenClaw session. Used by the intercept handler to stop OpenClaw's own processing.
public Task AbortSessionAsync(string sessionKey, CancellationToken ct = default)
Parameters
sessionKeystringctCancellationToken
Returns
ConnectAsync(CancellationToken)
Connects to the messaging platform.
public Task ConnectAsync(CancellationToken ct = default)
Parameters
Returns
DeleteSessionsByPrefixAsync(IEnumerable<string>, IEnumerable<string>?, bool, CancellationToken)
Deletes OpenClaw sessions whose keys begin with one of the provided prefixes. Intended for bridge-disable cleanup of JD.AI-managed session namespaces.
public Task<int> DeleteSessionsByPrefixAsync(IEnumerable<string> sessionKeyPrefixes, IEnumerable<string>? sessionKeyContains = null, bool deleteTranscript = true, CancellationToken ct = default)
Parameters
sessionKeyPrefixesIEnumerable<string>sessionKeyContainsIEnumerable<string>deleteTranscriptboolctCancellationToken
Returns
DisconnectAsync(CancellationToken)
Gracefully disconnects.
public Task DisconnectAsync(CancellationToken ct = default)
Parameters
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.
GetChannelStatusAsync(CancellationToken)
Gets channel status from the OpenClaw gateway.
public Task<RpcResponse> GetChannelStatusAsync(CancellationToken ct = default)
Parameters
Returns
GetSkillStatusAsync(CancellationToken)
Gets skill status from the OpenClaw gateway.
public Task<RpcResponse> GetSkillStatusAsync(CancellationToken ct = default)
Parameters
Returns
InjectMessageAsync(string, string, CancellationToken)
Injects a message into an OpenClaw session without triggering agent processing. Use this for injecting JD.AI-generated responses back into the conversation.
public Task InjectMessageAsync(string sessionKey, string content, CancellationToken ct = default)
Parameters
sessionKeystringcontentstringctCancellationToken
Returns
ListSessionsAsync(CancellationToken)
Lists all active sessions on the OpenClaw gateway.
public Task<RpcResponse> ListSessionsAsync(CancellationToken ct = default)
Parameters
Returns
RpcAsync(string, object?, CancellationToken)
Sends an arbitrary RPC request to the OpenClaw gateway.
public Task<RpcResponse> RpcAsync(string method, object? parameters = null, CancellationToken ct = default)
Parameters
methodstringparametersobjectctCancellationToken
Returns
SendMessageAsync(string, string, CancellationToken)
Sends a message to the specified conversation/thread.
public Task SendMessageAsync(string conversationId, string content, CancellationToken ct = default)
Parameters
conversationIdstringcontentstringctCancellationToken
Returns
Events
MessageReceived
Raised when a new inbound message arrives.
public event Func<ChannelMessage, Task>? MessageReceived
Event Type
Remarks
Uses Func<ChannelMessage, Task> instead of EventHandler to support async handlers.