Interface ITransport
Namespace: Libplanet.Net.Transports
Assembly: Libplanet.dll
Syntax
public interface ITransport : IDisposable
Properties
| Improve this Doc View SourceAsPeer
Peer representation of ITransport.
Declaration
Peer AsPeer { get; }
Property Value
| Type | Description |
|---|---|
| Peer |
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 SendMessageWithReplyAsync(BoundPeer, Message, Nullable<TimeSpan>, CancellationToken).
Declaration
AsyncDelegate<Message> ProcessMessageHandler { get; }
Property Value
| Type | Description |
|---|---|
| AsyncDelegate<Message> |
Running
Whether this ITransport instance is running.
Declaration
bool Running { get; }
Property Value
| Type | Description |
|---|---|
| Boolean | Gets the value indicates whether the instance is running. |
Methods
| Improve this Doc View SourceBroadcastMessage(Nullable<Address>, Message)
Broadcasts the message to peers selected from the routing table.
Declaration
void BroadcastMessage(Address? except, Message message)
Parameters
| Type | Name | Description |
|---|---|---|
| Nullable<Address> | except | An Address to exclude from broadcasting.
If |
| Message | message | A Message to broadcast. |
ReplyMessageAsync(Message, CancellationToken)
Replies message.
Declaration
Task ReplyMessageAsync(Message message, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Message | message | A Message to 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 the given message must be
matched to Identity of a message corresponding to the given
message.
SendMessageAsync(BoundPeer, Message, CancellationToken)
Sends the message to given peer.
Declaration
Task SendMessageAsync(BoundPeer peer, Message message, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundPeer | peer | A Peer to send message to. |
| Message | message | A Message to send. |
| CancellationToken | cancellationToken | A cancellation token used to propagate notification that this operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task | An awaitable task without value. |
SendMessageWithReplyAsync(BoundPeer, Message, Nullable<TimeSpan>, CancellationToken)
Sends the message
to given peer and waits for its single reply.
Declaration
Task<Message> SendMessageWithReplyAsync(BoundPeer peer, Message message, TimeSpan? timeout, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundPeer | peer | A Peer to send message to. |
| Message | message | A 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 |
SendMessageWithReplyAsync(BoundPeer, Message, Nullable<TimeSpan>, Int32, Boolean, CancellationToken)
Sends the message
to given peer and waits for its multiple replies.
Declaration
Task<IEnumerable<Message>> SendMessageWithReplyAsync(BoundPeer peer, Message message, TimeSpan? timeout, int expectedResponses, bool returnWhenTimeout, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundPeer | peer | A Peer to send message to. |
| Message | message | A 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 |
StartAsync(CancellationToken)
Initiates and runs transport layer.
Declaration
Task StartAsync(CancellationToken cancellationToken = null)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | A cancellation token used to propagate notification that this operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task | An awaitable task without value. |
StopAsync(TimeSpan, CancellationToken)
Stops running transport layer.
Declaration
Task StopAsync(TimeSpan waitFor, CancellationToken cancellationToken = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | waitFor | The |
| CancellationToken | cancellationToken | A cancellation token used to propagate notification that this operation should be canceled. |
Returns
| Type | Description |
|---|---|
| Task | An awaitable task without value. |
WaitForRunningAsync()
Waits until this ITransport instance gets started to run.
Declaration
Task WaitForRunningAsync()
Returns
| Type | Description |
|---|---|
| Task | A |