Show / Hide Table of Contents

Interface IMessageCodec<T>

Namespace: Libplanet.Net.Messages
Assembly: Libplanet.dll
Syntax
public interface IMessageCodec<T>
Type Parameters
Name Description
T

Methods

| Improve this Doc View Source

Decode(T, Boolean, Action<Byte[], Peer, AppProtocolVersion>, Nullable<TimeSpan>)

Decodes given -typed encoded into Message and checks its validity. Encode(Message, PrivateKey, Peer, DateTimeOffset, AppProtocolVersion)

Declaration
Message Decode(T encoded, bool reply, Action<byte[], Peer, AppProtocolVersion> appProtocolVersionValidator, TimeSpan? lifetime)
Parameters
Type Name Description
T encoded

A -typed instance to parse.

Boolean reply

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

Libplanet.Action<Byte[], Peer, AppProtocolVersion> appProtocolVersionValidator

The delegate validates the app protocol version of the message.

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

Exceptions
Type Condition
Libplanet.Net.DifferentAppProtocolVersionException

Thrown when local version does not match with given encoded's by given appProtocolVersionValidator.

InvalidMessageException

Thrown when given encoded's signer is invalid.

| Improve this Doc View Source

Encode(Message, PrivateKey, Peer, DateTimeOffset, AppProtocolVersion)

Encodes the message to -typed instance with given privateKey, peer and version.

Declaration
T Encode(Message message, PrivateKey privateKey, Peer peer, DateTimeOffset timestamp, AppProtocolVersion version)
Parameters
Type Name Description
Message message

A message to encode.

PrivateKey privateKey

A PrivateKey to sign message.

Peer peer

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

DateTimeOffset timestamp

The of the message is created.

AppProtocolVersion version

AppProtocolVersion-typed version of the transport layer.

Returns
Type Description
T

A containing the signed Message.

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