Class Message
Serves as the base class for messages used in ITransport.
Inherited Members
Namespace: Libplanet.Net.Messages
Assembly: Libplanet.dll
Syntax
public abstract class Message
Fields
| Improve this Doc View SourceCommonFrames
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 SourceDataFrames
Declaration
protected abstract IEnumerable<NetMQFrame> DataFrames { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<NetMQFrame> |
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[] |
Remote
The sender Peer of the message.
Declaration
public Peer Remote { get; set; }
Property Value
| Type | Description |
|---|---|
| Peer |
Timestamp
The timestamp of the message is created.
Declaration
public DateTimeOffset Timestamp { get; set; }
Property Value
| Type | Description |
|---|---|
| DateTimeOffset |
Type
Declaration
protected abstract Message.MessageType Type { get; }
Property Value
| Type | Description |
|---|---|
| Message.MessageType |
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 SourceDeserializePeer(Byte[])
Declaration
protected static Peer DeserializePeer(byte[] bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | bytes |
Returns
| Type | Description |
|---|---|
| Peer |
Parse(NetMQMessage, Boolean, AppProtocolVersion, IImmutableSet<PublicKey>, DifferentAppProtocolVersionEncountered, Nullable<TimeSpan>)
Casts given 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 |
| 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
|
| DifferentAppProtocolVersionEncountered | differentAppProtocolVersionEncountered | A delegate called back when a peer
with one different from |
| Nullable<TimeSpan> | lifetime | The lifetime of a message.
Messages generated before this value from the current time are ignored.
If |
Returns
| Type | Description |
|---|---|
| Message | A Message parsed from |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when empty |
| Libplanet.Net.DifferentAppProtocolVersionException | Thrown when
|
| InvalidMessageException | Thrown when given |
SerializePeer(Peer)
Declaration
protected byte[] SerializePeer(Peer peer)
Parameters
| Type | Name | Description |
|---|---|---|
| Peer | peer |
Returns
| Type | Description |
|---|---|
| Byte[] |
ToNetMQMessage(PrivateKey, Peer, DateTimeOffset, AppProtocolVersion)
Casts the message to 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 |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |