Table of Contents

Class ServiceProxy

Namespace
chia.dotnet
Assembly
chia-dotnet.dll

Base class that uses an IRpcClient to send and receive messages to services

public abstract class ServiceProxy : IServiceProxy
Inheritance
ServiceProxy
Implements
Derived
Inherited Members
Extension Methods

Remarks

The lifetime of the RpcClient is not controlled by the proxy. It should be disposed outside of this class.

Constructors

ServiceProxy(IRpcClient, string, string)

ctor

protected ServiceProxy(IRpcClient rpcClient, string destinationService, string originService)

Parameters

rpcClient IRpcClient

IRpcClient instance to use for rpc communication

destinationService string

Destination

originService string

Origin

Properties

DestinationService

public string DestinationService { get; init; }

Property Value

string
Base class that uses an to send and receive messages to services

IsEventSource

Indicates whether this instance is wired to a WebSocketRpcClient so may source events

public bool IsEventSource { get; }

Property Value

bool
Base class that uses an to send and receive messages to services

OriginService

The name of the service that is running. Will be used as the Origin of all messages as well as the identifier used for RegisterService(string, CancellationToken)

public string OriginService { get; init; }

Property Value

string
Base class that uses an to send and receive messages to services

RpcClient

The IRpcClient used for underlying RPC

public IRpcClient RpcClient { get; init; }

Property Value

IRpcClient
Base class that uses an to send and receive messages to services

Methods

CloseConnection(string, CancellationToken)

Closes a connection

public Task CloseConnection(string nodeId, CancellationToken cancellationToken = default)

Parameters

nodeId string

The id of the connection to close

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task

An awaitable Task

GetConnections(CancellationToken)

Get the service's connections

public Task<IEnumerable<ConnectionInfo>> GetConnections(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<ConnectionInfo>>

A list of ConnectionInfos

GetNetworkInfo(CancellationToken)

Retrieves information about the current network

public Task<(string NetworkName, string NetworkPrefix)> GetNetworkInfo(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<(string MyDid, string CoinID)>

The current network name and prefix

GetRoutes(CancellationToken)

Get all endpoints of a service

public Task<IEnumerable<string>> GetRoutes(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<string>>

A list of service routes

HealthZ(CancellationToken)

Sends heartbeat message to the service

public Task HealthZ(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task

Awaitable Task

Remarks

Either completes without error or throws an exception.

OnEventMessage(Message)

Called when an event message is received

protected virtual void OnEventMessage(Message msg)

Parameters

msg Message

Remarks

You need to call RegisterService(string, CancellationToken) with wallet_ui or metrics in order for service events to be generated.

OpenConnection(string, int, CancellationToken)

Add a connection

public Task OpenConnection(string host, int port, CancellationToken cancellationToken = default)

Parameters

host string

The host name of the connection

port int

The port to use

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task

An awaitable Task

StopNode(CancellationToken)

Stops the service

public Task StopNode(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task

Awaitable Task

Events

ConnectionAdded

Event raised when a connection is added

public event EventHandler<dynamic>? ConnectionAdded

Event Type

EventHandler<dynamic>
Base class that uses an to send and receive messages to services

Remarks

Requires registering as the metrics service

ConnectionClosed

Event raised when a connection is closed

public event EventHandler<dynamic>? ConnectionClosed

Event Type

EventHandler<dynamic>
Base class that uses an to send and receive messages to services

Remarks

Requires registering as the metrics service

ConnectionsChanged

Event raised when a get_connections broadcast message is received

public event EventHandler<dynamic>? ConnectionsChanged

Event Type

EventHandler<dynamic>
Base class that uses an to send and receive messages to services

UnrecognizedEvent

Event raised when a broadcast message is received that isn't recognized

public event EventHandler<Message>? UnrecognizedEvent

Event Type

EventHandler<Message>
Base class that uses an to send and receive messages to services