Interface ITransport
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 SourceAsPeer
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.
LastMessageTimestamp
The
Declaration
DateTimeOffset? LastMessageTimestamp { get; }
Property Value
Type | Description |
---|---|
Nullable<DateTimeOffset> |
ProcessMessageHandler
The list of tasks invoked when a message that is not a reply is received. To handle reply, please use SendMessageAsync(BoundPeer, Message, Nullable<TimeSpan>, CancellationToken).
Declaration
AsyncDelegate<Message> ProcessMessageHandler { get; }
Property Value
Type | Description |
---|---|
AsyncDelegate<Message> |
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
bool Running { get; }
Property Value
Type | Description |
---|---|
Boolean | The value indicating whether the instance is running. |
Methods
| Improve this Doc View SourceBroadcastMessage(IEnumerable<BoundPeer>, Message)
Broadcasts a Message to peers selected from the routing table.
Declaration
void BroadcastMessage(IEnumerable<BoundPeer> peers, Message message)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<BoundPeer> | peers | The BoundPeers to broadcast the
|
Message | message | A Message to broadcast. |
ReplyMessageAsync(Message, CancellationToken)
Sends a Message as a reply.
Declaration
Task ReplyMessageAsync(Message message, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
Message | message | The Message to send as a reply. |
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
The Identity of given message
must
match the Identity of the request Message
corresponding to message
.
SendMessageAsync(BoundPeer, Message, Nullable<TimeSpan>, CancellationToken)
Declaration
Task<Message> SendMessageAsync(BoundPeer peer, Message message, TimeSpan? timeout, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
BoundPeer | peer | The BoundPeer to send message to. |
Message | message | The Message 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 |
Exceptions
Type | Condition |
---|---|
CommunicationFailException | Thrown when fail send or receive a Message. |
SendMessageAsync(BoundPeer, Message, Nullable<TimeSpan>, Int32, Boolean, CancellationToken)
Declaration
Task<IEnumerable<Message>> SendMessageAsync(BoundPeer peer, Message message, TimeSpan? timeout, int expectedResponses, bool returnWhenTimeout, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
BoundPeer | peer | The BoundPeer to send message to. |
Message | message | The Message 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 |
Exceptions
Type | Condition |
---|---|
CommunicationFailException | Thrown when fail send or receive a Message. |
StartAsync(CancellationToken)
Starts running a transport layer as to put it in a Running state.
Declaration
Task StartAsync(CancellationToken cancellationToken = null)
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 |
StopAsync(TimeSpan, CancellationToken)
Stops running a transport layer as to put it in a not Running state.
Declaration
Task StopAsync(TimeSpan waitFor, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | waitFor | The |
CancellationToken | cancellationToken | The cancellation token to propagate a notification that this operation should be canceled. |
Returns
Type | Description |
---|---|
Task | An awaitable |
WaitForRunningAsync()
Waits until this ITransport instance gets started to run.
Declaration
Task WaitForRunningAsync()
Returns
Type | Description |
---|---|
Task | A |