Interface ITransport
Inherited Members
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 receive replies.
Properties
| Improve this Doc View SourceAppProtocolVersion
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 receive replies.
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.
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 receive replies.
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 receive replies.
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 receive replies.
Running
Whether this ITransport instance is running.
When the value is true, the ITransport can receive outside requests. When the value is false, the ITransport stops receiving 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 receive replies.
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 receive replies.
Methods
| Improve this Doc View SourceBroadcastMessage(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
|
MessageContent | content | A MessageContent to broadcast. |
Remarks
An instance of a transport implementing ITransport should always be able to send requests and receive replies.
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when ITransport instance is already disposed. |
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 receive replies.
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when ITransport instance is already disposed. |
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
|
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 |
Remarks
An instance of a transport implementing ITransport should always be able to send requests and receive replies.
Exceptions
Type | Condition |
---|---|
CommunicationFailException | Thrown when fail send or receive a Message. |
ObjectDisposedException | Thrown when ITransport instance is already disposed. |
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 |
Remarks
An instance of a transport implementing ITransport should always be able to send requests and receive replies.
Exceptions
Type | Condition |
---|---|
CommunicationFailException | Thrown when fail send or receive a Message. |
ObjectDisposedException | Thrown when ITransport instance is already disposed. |
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 receive replies.
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the instance is already disposed. |
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 receive replies.
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the instance is already disposed. |
WaitForRunningAsync()
Waits until this ITransport instance gets started to run.
Declaration
Task WaitForRunningAsync()
Returns
Type | Description |
---|---|
Task |
Remarks
An instance of a transport implementing ITransport should always be able to send requests and receive replies.