Show / Hide Table of Contents

Interface ITransport

An interface to handle peer-to-peer networking, including Message exchange and BoundPeer managing.

Inherited Members
IDisposable.Dispose()
Namespace: Libplanet.Net.Transports
Assembly: Libplanet.Net.dll
Syntax
public interface ITransport : IDisposable
Remarks

An instance of a transport implementing ITransport should always be able to send requests and recieve replies.

Properties

| Improve this Doc View Source

AppProtocolVersion

The application protocol version to comply.

Declaration
AppProtocolVersion AppProtocolVersion { get; }
Property Value
Type Description
AppProtocolVersion
Remarks

An instance of a transport implementing ITransport should always be able to send requests and recieve replies.

| Improve this Doc View Source

AsPeer

The current BoundPeer representation of ITransport.

Declaration
BoundPeer AsPeer { get; }
Property Value
Type Description
BoundPeer
Remarks

This creates a new instance of BoundPeer on the fly and can be different at different points of time depending on implementation, as ITransport may account for changing endpoint.

| Improve this Doc View Source

DifferentAppProtocolVersionEncountered

The callback triggered when a node encounters an AppProtocolVersion that is different from AppProtocolVersion that is signed by a trusted party, that is, one of TrustedAppProtocolVersionSigners. Does nothing by default.

Declaration
DifferentAppProtocolVersionEncountered DifferentAppProtocolVersionEncountered { get; }
Property Value
Type Description
DifferentAppProtocolVersionEncountered
Remarks

An instance of a transport implementing ITransport should always be able to send requests and recieve replies.

| Improve this Doc View Source

LastMessageTimestamp

The DateTimeOffset of the last message received.

Declaration
[Pure]
DateTimeOffset? LastMessageTimestamp { get; }
Property Value
Type Description
Nullable<DateTimeOffset>
Remarks

An instance of a transport implementing ITransport should always be able to send requests and recieve replies.

| Improve this Doc View Source

ProcessMessageHandler

The list of tasks invoked when a message that is not a reply is received.

Declaration
AsyncDelegate<Message> ProcessMessageHandler { get; }
Property Value
Type Description
AsyncDelegate<Message>
Remarks

An instance of a transport implementing ITransport should always be able to send requests and recieve replies.

| Improve this Doc View Source

Running

Whether this ITransport instance is running.

When the value is true, the ITransport can recieve outside requests. When the value is false, the ITransport stops recieving outside requests.

Declaration
[Pure]
bool Running { get; }
Property Value
Type Description
Boolean

The value indicating whether the instance is running.

Remarks

An instance of a transport implementing ITransport should always be able to send requests and recieve replies.

| Improve this Doc View Source

TrustedAppProtocolVersionSigners

The set of PublicKeys to trust when a node encounters a Message with an AppProtocolVersion that is different from AppProtocolVersion. Any Message with an untrusted AppProtocolVersion is ignored by the node. Set to an empty set of PublicKeys by default, i.e. not to trust any Message with a different AppProtocolVersion.

Declaration
IImmutableSet<PublicKey> TrustedAppProtocolVersionSigners { get; }
Property Value
Type Description
IImmutableSet<PublicKey>
Remarks

An instance of a transport implementing ITransport should always be able to send requests and recieve replies.

Methods

| Improve this Doc View Source

BroadcastMessage(IEnumerable<BoundPeer>, MessageContent)

Broadcasts a MessageContent to peers selected from the routing table.

Declaration
void BroadcastMessage(IEnumerable<BoundPeer> peers, MessageContent content)
Parameters
Type Name Description
IEnumerable<BoundPeer> peers

The BoundPeers to broadcast the content.

MessageContent content

A MessageContent to broadcast.

Remarks

An instance of a transport implementing ITransport should always be able to send requests and recieve replies.

Exceptions
Type Condition
ObjectDisposedException

Thrown when ITransport instance is already disposed.

| Improve this Doc View Source

ReplyMessageAsync(MessageContent, Byte[], CancellationToken)

Sends a MessageContent as a reply.

Declaration
Task ReplyMessageAsync(MessageContent content, byte[] identity, CancellationToken cancellationToken)
Parameters
Type Name Description
MessageContent content

The MessageContent to send as a reply.

Byte[] identity

The byte array that represents identification of the MessageContent to respond.

CancellationToken cancellationToken

A cancellation token used to propagate notification that this operation should be canceled.

Returns
Type Description
Task

An awaitable task without value.

Remarks

An instance of a transport implementing ITransport should always be able to send requests and recieve replies.

Exceptions
Type Condition
ObjectDisposedException

Thrown when ITransport instance is already disposed.

| Improve this Doc View Source

SendMessageAsync(BoundPeer, MessageContent, Nullable<TimeSpan>, Int32, Boolean, CancellationToken)

Sends a MessageContent to a given BoundPeer and waits for its multiple replies.

Declaration
Task<IEnumerable<Message>> SendMessageAsync(BoundPeer peer, MessageContent content, TimeSpan? timeout, int expectedResponses, bool returnWhenTimeout, CancellationToken cancellationToken)
Parameters
Type Name Description
BoundPeer peer

The BoundPeer to send message to.

MessageContent content

The MessageContent to send.

Nullable<TimeSpan> timeout

A timeout of waiting for the reply of the message.

Int32 expectedResponses

The number of expected replies for the message.

Boolean returnWhenTimeout

Determines the behavior when failed to receive expectedResponses messages and timeout occurred.

CancellationToken cancellationToken

A cancellation token used to propagate notification that this operation should be canceled.

Returns
Type Description
Task<IEnumerable<Message>>

The replies of the content sent by peer.

Remarks

An instance of a transport implementing ITransport should always be able to send requests and recieve replies.

Exceptions
Type Condition
CommunicationFailException

Thrown when fail send or receive a Message.

ObjectDisposedException

Thrown when ITransport instance is already disposed.

| Improve this Doc View Source

SendMessageAsync(BoundPeer, MessageContent, Nullable<TimeSpan>, CancellationToken)

Sends a MessageContent to a given BoundPeer and waits for its single reply.

Declaration
Task<Message> SendMessageAsync(BoundPeer peer, MessageContent content, TimeSpan? timeout, CancellationToken cancellationToken)
Parameters
Type Name Description
BoundPeer peer

The BoundPeer to send message to.

MessageContent content

The MessageContent to send.

Nullable<TimeSpan> timeout

A timeout of waiting for the reply of the message.

CancellationToken cancellationToken

A cancellation token used to propagate notification that this operation should be canceled.

Returns
Type Description
Task<Message>

The replies of the content sent by peer.

Remarks

An instance of a transport implementing ITransport should always be able to send requests and recieve replies.

Exceptions
Type Condition
CommunicationFailException

Thrown when fail send or receive a Message.

ObjectDisposedException

Thrown when ITransport instance is already disposed.

| Improve this Doc View Source

StartAsync(CancellationToken)

Starts running a transport layer as to put it in a Running state.

Declaration
Task StartAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
CancellationToken cancellationToken

The cancellation token to propagate a notification that this operation should be canceled.

Returns
Type Description
Task

An awaitable Task without a value.

Remarks

An instance of a transport implementing ITransport should always be able to send requests and recieve replies.

Exceptions
Type Condition
ObjectDisposedException

Thrown when the instance is already disposed.

| Improve this Doc View Source

StopAsync(TimeSpan, CancellationToken)

Stops running a transport layer as to put it in a not Running state.

Declaration
Task StopAsync(TimeSpan waitFor, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
TimeSpan waitFor

The TimeSpan to delay before actual stopping.

CancellationToken cancellationToken

The cancellation token to propagate a notification that this operation should be canceled.

Returns
Type Description
Task

An awaitable Task without a value.

Remarks

An instance of a transport implementing ITransport should always be able to send requests and recieve replies.

Exceptions
Type Condition
ObjectDisposedException

Thrown when the instance is already disposed.

| Improve this Doc View Source

WaitForRunningAsync()

Waits until this ITransport instance gets started to run.

Declaration
Task WaitForRunningAsync()
Returns
Type Description
Task

A Task completed when Running property becomes true.

Remarks

An instance of a transport implementing ITransport should always be able to send requests and recieve replies.

  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium