Skip to main content

Protocol API

Namespace: K13A.TSMP

These types are useful for tests, tools, custom codecs, validators, and diagnostics.

FrameHeader

Constants:

ConstantValue
Size56
BytesBeforeCrc52
CrcOffset52
MaxCodecOptionBytes5

Important methods:

MethodUse
CreateDefault()Create a default network frame header.
WriteTo(byte[] buffer, int offset)Write header and CRC.
TryRead(...)Native read/validate helper.
ClampDecodeSampleSize(...)Clamp decode sampling size.

The header CRC is always written by WriteTo.

FrameHeaderReader

Validation statuses:

StatusMeaning
StatusOkHeader is valid.
StatusInvalidBufferBuffer range is invalid.
StatusMagicMismatchMagic does not match TSMP.
StatusHeaderSizeMismatchHeader size is not supported.
StatusVersionMismatchMajor version is not supported.
StatusCrcMismatchHeader CRC failed.

Use reader status codes in tests and tools instead of parsing error strings.

Protocol enums

TypeValues
SymbolModeLuma4
PayloadTypeEmpty, NetworkFrame
NetworkMessageTypeVariableState, RpcCall
NetworkValueTypeBool, Int32, Float32, vectors, quaternion, UTF8 string, raw bytes, supported arrays.
NetworkSyncDirectionSendReceive, SendOnly, ReceiveOnly
RPCTargetLocal, Remote, All

Network frame helpers

TypeUse
NetworkFrameProtocolPayload offsets, sizes, and constants.
NetworkFrameWriterWrites network frame and message headers.
NetworkFrameReaderReads network frame and message headers.
NetworkValueCodecMaps supported C# value types to TSMP value types.
BinaryLittle-endian integer read/write helpers.
StableHashStable FNV-1a hash helpers.
Crc32RuntimeRuntime CRC32 table and compute helpers.

Frame helpers

TypeUse
FrameLayoutCalculates active block layout from width, height, and block size.
FrameCapacityCalculates available frame/payload capacity.
FrameHeaderWriterHeader writing helpers.

Hashing rule

TSMP uses stable hashes for field keys and RPC method names. Do not use runtime-generated strings as keys if sender and receiver need to match reliably.