Show / Hide Table of Contents

Class NetMQTransport

Implementation of ITransport interface using NetMQ.

Inheritance
Object
NetMQTransport
Implements
ITransport
IDisposable
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Libplanet.Net.Transports
Assembly: Libplanet.Net.dll
Syntax
public class NetMQTransport : ITransport, IDisposable

Properties

| Improve this Doc View Source

AppProtocolVersion

The application protocol version to comply.

Declaration
public AppProtocolVersion AppProtocolVersion { get; }
Property Value
Type Description
AppProtocolVersion
| Improve this Doc View Source

AsPeer

The current BoundPeer representation of ITransport.

Declaration
public 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.

| Improve this Doc View Source

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
public DifferentAppProtocolVersionEncountered DifferentAppProtocolVersionEncountered { get; }
Property Value
Type Description
DifferentAppProtocolVersionEncountered
| Improve this Doc View Source

LastMessageTimestamp

The DateTimeOffset of the last message received.

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

ProcessMessageHandler

The list of tasks invoked when a message that is not a reply is received.

Declaration
public AsyncDelegate<Message> ProcessMessageHandler { get; }
Property Value
Type Description
AsyncDelegate<Message>
| Improve this Doc View Source

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
public bool Running { get; }
Property Value
Type Description
Boolean

The value indicating whether the instance is running.

| Improve this Doc View Source

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
public IImmutableSet<PublicKey> TrustedAppProtocolVersionSigners { get; }
Property Value
Type Description
IImmutableSet<PublicKey>

Methods

| Improve this Doc View Source

BroadcastMessage(IEnumerable<BoundPeer>, MessageContent)

Broadcasts a MessageContent to peers selected from the routing table.

Declaration
public void BroadcastMessage(IEnumerable<BoundPeer> peers, MessageContent content)
Parameters
Type Name Description
IEnumerable<BoundPeer> peers

The BoundPeers to broadcast the content.

MessageContent content

A MessageContent to broadcast.

Exceptions
Type Condition
ObjectDisposedException

Thrown when ITransport instance is already disposed.

| Improve this Doc View Source

Create(PrivateKey, AppProtocolVersionOptions, HostOptions, Nullable<TimeSpan>)

Creates an initialized NetMQTransport instance.

Declaration
public static async Task<NetMQTransport> Create(PrivateKey privateKey, AppProtocolVersionOptions appProtocolVersionOptions, HostOptions hostOptions, TimeSpan? messageTimestampBuffer = null)
Parameters
Type Name Description
PrivateKey privateKey

PrivateKey of the transport layer.

AppProtocolVersionOptions appProtocolVersionOptions

The AppProtocolVersionOptions to use when handling an AppProtocolVersion attached to a Message.

HostOptions hostOptions

The HostOptions to use when binding to the network.

Nullable<TimeSpan> messageTimestampBuffer

The amount in TimeSpan that is allowed for the timestamp of a Message to differ from the current time of a local node. Every Message with its timestamp differing greater than messageTimestampBuffer will be ignored. If null, any timestamp is accepted.

Returns
Type Description
Task<NetMQTransport>

An awaitable Task returning a NetMQTransport when awaited that is ready to send request Messages and receive reply Messages.

| Improve this Doc View Source

Dispose()

Implementation of ITransport interface using NetMQ.

Declaration
public void Dispose()
| Improve this Doc View Source

ReplyMessageAsync(MessageContent, Byte[], CancellationToken)

Sends a MessageContent as a reply.

Declaration
public async 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.

Exceptions
Type Condition
ObjectDisposedException

Thrown when ITransport instance is already disposed.

| Improve this Doc View Source

SendMessageAsync(BoundPeer, MessageContent, Nullable<TimeSpan>, Int32, Boolean, CancellationToken)

Sends a MessageContent to a given BoundPeer and waits for its multiple replies.

Declaration
public async 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 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 content sent by peer.

Exceptions
Type Condition
CommunicationFailException

Thrown when fail send or receive a Message.

ObjectDisposedException

Thrown when ITransport instance is already disposed.

| Improve this Doc View Source

SendMessageAsync(BoundPeer, MessageContent, Nullable<TimeSpan>, CancellationToken)

Sends a MessageContent to a given BoundPeer and waits for its single reply.

Declaration
public async 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 content sent by peer.

Exceptions
Type Condition
CommunicationFailException

Thrown when fail send or receive a Message.

ObjectDisposedException

Thrown when ITransport instance is already disposed.

| Improve this Doc View Source

StartAsync(CancellationToken)

Starts running a transport layer as to put it in a Running state.

Declaration
public async 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.

Exceptions
Type Condition
ObjectDisposedException

Thrown when the instance is already disposed.

| Improve this Doc View Source

StopAsync(TimeSpan, CancellationToken)

Stops running a transport layer as to put it in a not Running state.

Declaration
public async 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.

Exceptions
Type Condition
ObjectDisposedException

Thrown when the instance is already disposed.

| Improve this Doc View Source

WaitForRunningAsync()

Waits until this ITransport instance gets started to run.

Declaration
public Task WaitForRunningAsync()
Returns
Type Description
Task

A Task completed when Running property becomes true.

Implements

ITransport
System.IDisposable
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium