Show / Hide Table of Contents

Class Message

Serves as the base class for messages used in ITransport.

Inheritance
Object
Message
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Libplanet.Net.Messages
Assembly: Libplanet.dll
Syntax
public abstract class Message

Fields

| Improve this Doc View Source

CommonFrames

The number of frames that all messages commonly contain.

Declaration
public const int CommonFrames = 5
Field Value
Type Description
Int32

Properties

| Improve this Doc View Source

DataFrames

Declaration
protected abstract IEnumerable<NetMQFrame> DataFrames { get; }
Property Value
Type Description
IEnumerable<NetMQFrame>
| Improve this Doc View Source

Identity

byte[]-typed identity of the message. If a message B is the reply of the message A, B's identity must be set to A's identity.

Declaration
public byte[] Identity { get; set; }
Property Value
Type Description
Byte[]
| Improve this Doc View Source

Remote

The sender Peer of the message.

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

Timestamp

The timestamp of the message is created.

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

Type

Declaration
protected abstract Message.MessageType Type { get; }
Property Value
Type Description
Message.MessageType
| Improve this Doc View Source

Version

AppProtocolVersion-typed version of the Remote's transport layer.

Declaration
public AppProtocolVersion Version { get; set; }
Property Value
Type Description
AppProtocolVersion

Methods

| Improve this Doc View Source

DeserializePeer(Byte[])

Declaration
protected static Peer DeserializePeer(byte[] bytes)
Parameters
Type Name Description
Byte[] bytes
Returns
Type Description
Peer
| Improve this Doc View Source

Parse(NetMQMessage, Boolean, AppProtocolVersion, IImmutableSet<PublicKey>, DifferentAppProtocolVersionEncountered, Nullable<TimeSpan>)

Casts given -typed raw into Message and checks its validity. ToNetMQMessage(PrivateKey, Peer, DateTimeOffset, AppProtocolVersion)

Declaration
public static Message Parse(NetMQMessage raw, bool reply, AppProtocolVersion localVersion, IImmutableSet<PublicKey> trustedAppProtocolVersionSigners, DifferentAppProtocolVersionEncountered differentAppProtocolVersionEncountered, TimeSpan? lifetime)
Parameters
Type Name Description
NetMQMessage raw

A to parse.

Boolean reply

A flag to express whether the target is a reply of other message.

AppProtocolVersion localVersion

The AppProtocolVersion-typed version of the local transport layer. ITransport

IImmutableSet<PublicKey> trustedAppProtocolVersionSigners

PublicKeys of parties to trust AppProtocolVersions they signed. To trust any party, pass null.

DifferentAppProtocolVersionEncountered differentAppProtocolVersionEncountered

A delegate called back when a peer with one different from localVersion, and their version is signed by a trusted party (i.e., trustedAppProtocolVersionSigners). If this callback returns false, an encountered peer is ignored. If this callback is omitted, all peers with different AppProtocolVersions are ignored.

Nullable<TimeSpan> lifetime

The lifetime of a message. Messages generated before this value from the current time are ignored. If null is given, messages will not be ignored by its timestamp.

Returns
Type Description
Message

A Message parsed from raw.

Exceptions
Type Condition
ArgumentException

Thrown when empty raw is given.

Libplanet.Net.DifferentAppProtocolVersionException

Thrown when localVersion does not match with given raw's Version, and their version is signed by a trusted party (i.e., trustedAppProtocolVersionSigners), and differentAppProtocolVersionEncountered is null or its return value is false.

InvalidMessageException

Thrown when given raw's signer is invalid.

| Improve this Doc View Source

SerializePeer(Peer)

Declaration
protected byte[] SerializePeer(Peer peer)
Parameters
Type Name Description
Peer peer
Returns
Type Description
Byte[]
| Improve this Doc View Source

ToNetMQMessage(PrivateKey, Peer, DateTimeOffset, AppProtocolVersion)

Casts the message to with given key, peer and version.

Declaration
public NetMQMessage ToNetMQMessage(PrivateKey key, Peer peer, DateTimeOffset timestamp, AppProtocolVersion version)
Parameters
Type Name Description
PrivateKey key

A PrivateKey to sign message.

Peer peer

Peer-typed representation of the sender's transport layer. AsPeer

DateTimeOffset timestamp

The DateTimeOffset of the message is created.

AppProtocolVersion version

AppProtocolVersion-typed version of the transport layer.

Returns
Type Description
NetMQMessage

A containing the signed Message.

Exceptions
Type Condition
ArgumentNullException

Thrown when peer is null.

  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2021 Planetarium