Class TcpMessageCodec
Implements
Namespace: Libplanet.Net.Messages
Assembly: Libplanet.dll
Syntax
public class TcpMessageCodec : object, IMessageCodec<byte[]>
Constructors
| Improve this Doc View SourceTcpMessageCodec(Nullable<TimeSpan>)
Creates a TcpMessageCodec instance.
Declaration
public TcpMessageCodec(TimeSpan? messageLifespan = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Nullable<TimeSpan> | messageLifespan | Lifespan to use for messages when decoding. |
Methods
| Improve this Doc View SourceDecode(Byte[], Boolean, Action<Byte[], Peer, AppProtocolVersion>)
Decodes given encoded into
Message and checks its validity.
Encode(Message, PrivateKey, Peer, DateTimeOffset, AppProtocolVersion)
Declaration
public Message Decode(byte[] encoded, bool reply, Action<byte[], Peer, AppProtocolVersion> appProtocolVersionValidator)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | encoded | |
| 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. |
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
public byte[] 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 |
|---|---|
| Byte[] | A |