본문으로 건너뛰기

Protocol API

Namespace: K13A.TSMP

이 타입들은 test, tool, custom codec, validator, diagnostics에 유용합니다.

FrameHeader

Constants:

ConstantValue
Size56
BytesBeforeCrc52
CrcOffset52
MaxCodecOptionBytes5

Important methods:

Method용도
CreateDefault()Default network frame header를 만듭니다.
WriteTo(byte[] buffer, int offset)Header와 CRC를 씁니다.
TryRead(...)Native read/validate helper.
ClampDecodeSampleSize(...)Decode sampling size를 clamp합니다.

WriteTo는 항상 header CRC를 씁니다.

FrameHeaderReader

Validation statuses:

Status의미
StatusOkHeader가 valid입니다.
StatusInvalidBufferBuffer range가 invalid입니다.
StatusMagicMismatchMagic이 TSMP와 일치하지 않습니다.
StatusHeaderSizeMismatchHeader size가 지원되지 않습니다.
StatusVersionMismatchMajor version이 지원되지 않습니다.
StatusCrcMismatchHeader CRC가 실패했습니다.

Test와 tool에서는 error string을 parsing하지 말고 reader status code를 사용하세요.

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

Type용도
NetworkFrameProtocolPayload offsets, sizes, constants.
NetworkFrameWriterNetwork frame과 message headers를 씁니다.
NetworkFrameReaderNetwork frame과 message headers를 읽습니다.
NetworkValueCodecSupported C# value types를 TSMP value types로 mapping합니다.
BinaryLittle-endian integer read/write helpers.
StableHashStable FNV-1a hash helpers.
Crc32RuntimeRuntime CRC32 table과 compute helpers.

Frame helpers

Type용도
FrameLayoutWidth, height, block size로 active block layout을 계산합니다.
FrameCapacityFrame/payload capacity를 계산합니다.
FrameHeaderWriterHeader writing helpers.

Hashing rule

TSMP는 field key와 RPC method name에 stable hash를 사용합니다. Sender와 receiver가 안정적으로 맞아야 한다면 runtime-generated string을 key로 사용하지 마세요.