Skip to main content

Network frame API

The TSMP network payload is a compact message stream inside the frame payload. It contains variable state messages and RPC messages.

Network frame structure

PartPurpose
Network frame headerVersion, message count, and payload-level metadata.
Variable state messageOne networkId plus one or more variable values.
RPC messageOne networkId, one method hash, and optional arguments.
Value payloadTyped bytes for primitives, strings, arrays, or packed byte[] data.

Empty variable messages should not be written. If a component has no enabled fields, the builder rolls back the message.

Variable state messages

A variable state message identifies a target behaviour by networkId, then contains field entries:

EntryMeaning
variableHashStable hash of the [TransSync] key or field name.
NetworkValueTypeEncoded value type.
LengthRequired for strings, arrays, and raw bytes.
DataValue bytes.

The decoder applies the value only when a binding matches the network ID, variable hash, direction, and target field.

RPC messages

An RPC message identifies a target behaviour by networkId and a method by hash. TSMPNetworkBehaviour.SendTransRPC() is the normal entry point.

TargetBehaviour
RPCTarget.LocalExecute locally only. No remote texture event is required.
RPCTarget.RemoteQueue for receivers only.
RPCTarget.AllExecute locally and queue for receivers.

Value types

Supported synchronized values include primitive numeric types, bool, Vector2, Vector3, Quaternion, string, byte[], and supported arrays. Use byte[] for dense high-frequency data.

Binary helper use

Protocol helpers read and write little-endian values. For custom packed payloads, keep a version byte at offset zero so receivers can handle future changes safely.