Skip to content

Serialization

JDare edited this page Jul 10, 2020 · 1 revision

All of the object serialization is currently done using Godots built in binary serialization functions var2bytes and bytes2var. The packet byte arrays are written in the order:

  • PACKET_TYPE
  • Payload

The payload is typically an array of all the variants needed for a request, e.g. node path/cache index, method name, arguments.

For example:

var packet = PoolByteArray()
packet.append(PACKET_TYPE.RPC)
var payload = [path_cache_index, method, args]
packet.append_array(var2bytes(payload))

Using the built in serialization gives us the benefit of including native Godot variant support e.g. Vector2, Color, etc. For a full list, see https://docs.godotengine.org/en/stable/tutorials/misc/binary_serialization_api.html

Clone this wiki locally