Skip to main content

ClientCommandHandler.ReceivedMessage

A private class in Root.Township, the global namespace. Reach it through att-stubs' publicized assemblies or Harmony's AccessTools.

Buffer that rebuilds one length-prefixed message from a ClientCommandHandler socket stream: a 4-byte size, a 1-byte type, then the payload.

Constructors​

MemberWhat it is
ReceivedMessage(ClientCommandHandler handler)Creates a ClientCommandHandler.ReceivedMessage from handler.

Fields​

MemberWhat it is
const int HeaderSizeBytes before the payload: 4 for the size and 1 for the type.
const int MaxMessageSizeSize of the receive buffer, 65535.
4 private and internal fields
MemberWhat it is
private ClientCommandHandler handlerThe ClientCommandHandler that gets finished messages.
private bool hasReadMessageSizeWhether the size header has been read.
private int leftToReadBytes still to come, including the type byte.
private const int MessageSizeSizeBytes in the size field, 4.

Properties​

MemberWhat it is
byte[] Data { get; set; }Receive buffer, 65535 bytes.
int Index { get; set; }Write position in Data.
bool IsFullyRead { get; set; }True once the whole message has arrived.
int MessageSize { get; set; }Payload size read from the header.

Methods​

MemberWhat it is
void Process()Hands the type byte and payload to the handler, logs any exception to the console, then clears.
int Read(byte[] data, int offset, int packetLength)Copies bytes from a received packet into the buffer. Returns how many were used, so the rest can start the next message.
2 private and internal methods
MemberWhat it is
private void Clear()Resets the buffer for the next message.
private void ReadMessageSize()Reads the payload size from the first 4 bytes.

Used in​

Members of other types that take, return or hold a ReceivedMessage: