Table of Contents

Interface IPeerCommunicationService

Namespace
NLightning.Domain.Node.Interfaces
Assembly
NLightning.Domain.dll

Interface for communication with a single peer.

public interface IPeerCommunicationService

Properties

IsConnected

Gets a value indicating whether the connection is established.

bool IsConnected { get; }

Property Value

bool

PeerCompactPubKey

Gets the peer's public key.

CompactPubKey PeerCompactPubKey { get; }

Property Value

CompactPubKey

Methods

Disconnect()

Disconnects from the peer.

void Disconnect()

InitializeAsync(TimeSpan)

Initializes the communication with the peer.

Task InitializeAsync(TimeSpan networkTimeout)

Parameters

networkTimeout TimeSpan

The network timeout.

Returns

Task

A task that represents the asynchronous operation.

SendMessageAsync(IMessage, CancellationToken)

Sends a message to the peer.

Task SendMessageAsync(IMessage message, CancellationToken cancellationToken = default)

Parameters

message IMessage

The message to send.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

A task that represents the asynchronous operation.

Events

DisconnectEvent

Event raised when the peer is disconnected.

event EventHandler? DisconnectEvent

Event Type

EventHandler

ExceptionRaised

Event raised when an exception occurs.

event EventHandler<Exception>? ExceptionRaised

Event Type

EventHandler<Exception>

MessageReceived

Event raised when a message is received from the peer.

event EventHandler<IMessage?> MessageReceived

Event Type

EventHandler<IMessage>