Interface ITransport
Inherited Members
Namespace: Libplanet.Net.Transports
Assembly: Libplanet.dll
Syntax
public interface ITransport : IDisposable
Properties
| Improve this Doc View SourceAsPeer
Peer representation of ITransport.
Declaration
[Pure]
Peer AsPeer { get; }
Property Value
Type | Description |
---|---|
Peer |
LastMessageTimestamp
The DateTimeOffset of the last message was received.
Declaration
[Pure]
DateTimeOffset? LastMessageTimestamp { get; }
Property Value
Type | Description |
---|---|
Nullable<DateTimeOffset> |
Running
Whether this ITransport instance is running.
Declaration
[Pure]
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. |
ReplyMessage(Message)
Replies message.
Declaration
void ReplyMessage(Message message)
Parameters
Type | Name | Description |
---|---|---|
Message | message | A Message to reply. |
Remarks
The Identity of the given message
must be
matched to Identity of a message corresponding to the given
message
.
RunAsync(CancellationToken)
Starts running transport layer. To RunAsync(CancellationToken), you should call StartAsync(CancellationToken) first.
Declaration
Task RunAsync(CancellationToken cancellationToken = default(CancellationToken))
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. |
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>, 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 |
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 |
StartAsync(CancellationToken)
Initiates transport layer.
Declaration
Task StartAsync(CancellationToken cancellationToken = default(CancellationToken))
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 = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | waitFor | The TimeSpan of delay before actual stopping. |
CancellationToken | cancellationToken | A cancellation token used to propagate notification that this operation should be canceled. |
Returns
Type | Description |
---|---|
Task | An awaitable task without value. |
Events
| Improve this Doc View SourceProcessMessageHandler
The EventHandler invoked when a message that is not a reply is received. To handle reply, please use SendMessageWithReplyAsync(BoundPeer, Message, Nullable<TimeSpan>, CancellationToken).
Declaration
event EventHandler<Message> ProcessMessageHandler
Event Type
Type | Description |
---|---|
EventHandler<Message> |