Skip to main content

MessageProcessor

A static class in Root.Township, Alta.Networking.Internal.

Reads single messages out of received packet data and runs the connection's handler for each message type. Used by the connection receivers on both sides.

Fields​

MemberWhat it is
static Logger MessageLoggerThe MessageDebug logger that traces every message read and written.
6 private and internal fields
MemberWhat it is
private static Logger loggerNLog logger for errors.
private static StreamReader messageReaderShared reader over receiveBuffer.
private static readonly uint[] receiveBufferShared buffer the message bytes are copied into before reading.
private const int receiveBufferSizeLength of receiveBuffer (2048 entries).
private static readonly ushort[] sizeOne-entry buffer the length prefix is copied into.
private const int UShortByteSizeSize of the length prefix, 2 bytes.

Methods​

MemberWhat it is
static int ProcessSingleMessageFromData(Connection connection, ArraySegment<byte> data, ConnectionChannel channel, out MessageType messageType)Reads a 2 byte length, then one message with a 5 bit type, handles it and returns the bytes used.
1 private and internal method
MemberWhat it is
private static bool HandleMessage(Connection connection, Stream stream, MessageType type, ConnectionChannel channel)Finds the connection's handler for the message type and runs it, logging unsupported types and handler exceptions.