Show / Hide Table of Contents

Interface ITransport

An interface to handle peer-to-peer networking, including Message exchanging and Peer managing.

Namespace: Libplanet.Net.Transports
Assembly: Libplanet.dll
Syntax
public interface ITransport : IDisposable

Properties

| Improve this Doc View Source

AsPeer

Peer representation of ITransport.

Declaration
Peer AsPeer { get; }
Property Value
Type Description
Peer
| Improve this Doc View Source

LastMessageTimestamp

The of the last message was received.

Declaration
DateTimeOffset? LastMessageTimestamp { get; }
Property Value
Type Description
Nullable<DateTimeOffset>
| Improve this Doc View Source

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 Source

BroadcastMessage(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 null is given, no peers will be excluded.

Message message

A Message to broadcast.

| Improve this Doc View Source

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.

| Improve this Doc View Source

RunAsync(CancellationToken)

Starts running transport layer. To RunAsync(CancellationToken), you should call StartAsync(CancellationToken) first.

Declaration
Task RunAsync(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 message sent by peer.

| Improve this Doc View Source

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 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 message sent by peer.

| Improve this Doc View Source

StartAsync(CancellationToken)

Initiates 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.

| Improve this Doc View Source

StopAsync(TimeSpan, CancellationToken)

Stops running transport layer.

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

The 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 Source

ProcessMessageHandler

The 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>
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2021 Planetarium