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 SourceDecode(T, Boolean, Action<Byte[], Peer, AppProtocolVersion>, Nullable<TimeSpan>)
Decodes given 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 |
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 |
Returns
Type | Description |
---|---|
Message | A Message parsed from |
Exceptions
Type | Condition |
---|---|
Libplanet.Net.DifferentAppProtocolVersionException | Thrown when
local version does not match with given |
InvalidMessageException | Thrown when given |
Encode(Message, PrivateKey, Peer, DateTimeOffset, AppProtocolVersion)
Encodes the message to 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 |
AppProtocolVersion | version | AppProtocolVersion-typed version of the transport layer. |
Returns
Type | Description |
---|---|
T | A |