Skip to content

Photons

This section outlines the internal structure of the Photon protocol, detailing the commands, reliable message events, and the specific parameter serialization types for both Version 16 and Version 18.

Commands Types

Commands are the fundamental building blocks of the Photon network layer, handling connection state and data delivery.

Command TypeNote
AcknowledgeCommandReceipt of reliable commands.
ConnectCommandInitiates a connection.
VerifyConnectCommandVerifies connection establishment.
DisconnectCommandGracefully closes a connection.
PingCommandKeep-alive ping message.
SendReliableCommandSends reliable data (guaranteed delivery).
SendUnreliableCommandSends unreliable data (best effort).
SendReliableFragmentCommandSends a fragment of a large reliable message.

Events Types

These define the different kinds of reliable messages that can be exchanged once a connection is established.

Event TypeDescription
OperationRequestClient requests an operation.
OtherOperationResponseAlternative response format.
EventDataTypeServer sends an event to the client.
ExchangeKeysKey exchange for encryption.
OperationResponseServer responds to an operation.

Supported Parameters Types

The Photon protocol serializes parameters using specific type bytes. While the core primitives are fully handled, some complex or nested data structures are still in development. The serialization format changed significantly between Version 16 and Version 18.

Version 16

Version 16 uses a straightforward mapping of types to specific hexadecimal bytes.

Type NameSupportedDescription
UnknownTypeUnknown or unsupported type.
NilTypeNull/nil value.
DictionaryTypeDictionary with fixed key/value types.
StringArrayTypeArray of strings.
Int8Type8-bit signed integer.
Custom🏗️Custom serialized object.
DoubleTypeAlias for Float64Type.
EventDateType🏗️Event date/time.
Float32Type32-bit floating point.
Float64Type64-bit floating point.
HashTableTypeHashtable with mixed key/value types.
Int32Type32-bit signed integer.
Int16Type16-bit signed integer.
Int64Type64-bit signed integer.
Int32ArrayTypeArray of 32-bit integers.
BooleanTypeBoolean (0x00=false, 0x01=true).
OperationResponseType🏗️Operation response message.
OperationRequestType🏗️Operation request message.
StringTypeUTF-8 string with uint16 length prefix.
Int8ArrayTypeArray of 8-bit integers.
ArrayTypeGeneric typed array.
ObjectArrayType🏗️Array of serialized objects.

Version 18

Version 18 introduces a more complex and optimized serialization format, including compressed types, cast types, and zero-shorthands (where the type code itself represents the entire value).

Core & Compressed Types

Type NameSupportedDescription
UnknownTypeUnknown type.
BooleanTypeStandard boolean.
Int8Type8-bit integer.
Int16Type16-bit integer.
Float32Type32-bit floating point.
Float64Type64-bit floating point.
StringTypeUTF-8 String.
NilTypeNull/nil value.
CompressedInt32TypeZigzag compressed 32-bit integer.
CompressedInt64TypeZigzag compressed 64-bit integer.

Cast Types (Optimized Numbers)

Type NameSupportedDescription
Int8Positive1 byte unsigned, cast to +int32.
Int8Negative1 byte unsigned, cast to -int32.
Int16Positive2 bytes unsigned, cast to +int32.
Int16Negative2 bytes unsigned, cast to -int32.
Long8Positive1 byte unsigned, cast to +int64.
Long8Negative1 byte unsigned, cast to -int64.
Long16Positive2 bytes unsigned, cast to +int64.
Long16Negative2 bytes unsigned, cast to -int64.

Complex & Custom Types

Type NameSupportedDescription
CustomType🏗️Custom serialized object.
CustomTypeSlim🏗️Slim custom object.
DictionaryTypeTyped dictionary.
HashtableTypeMixed type hashtable.
ObjectArrayType🏗️Array of objects.
OperationRequestType🏗️Request payload.
OperationResponseType🏗️Response payload.
EventDataType🏗️Event payload.

Zero Shorthands

These types have no payload bytes; the type code itself dictates the value (e.g., 0, false, true).

Type NameSupportedNote
BooleanFalseTypeRepresents false.
BooleanTrueTypeRepresents true.
ShortZeroTypeRepresents int16(0).
IntZeroTypeRepresents int32(0).
LongZeroTypeRepresents int64(0).
FloatZeroTypeRepresents float32(0).
DoubleZeroTypeRepresents float64(0).
ByteZeroTypeRepresents byte(0).

Arrays

In Version 18, array elements are baked directly into the type code using a bitwise OR operation (ElementType | ArrayType).

Type NameSupported VersionFormula
ArrayType (Container)Base Array Container
BooleanArrayTypeBooleanType | ArrayType
ByteArrayTypeInt8Type | ArrayType
ShortArrayTypeInt16Type | ArrayType
Float32ArrayTypeFloat32Type | ArrayType
Float64ArrayTypeFloat64Type | ArrayType
StringArrayTypeStringType | ArrayType
CompressedIntArrayTypeCompressedInt32Type | ArrayType
CompressedLongArrayTypeCompressedInt64Type | ArrayType
CustomTypeArrayType🏗️CustomType | ArrayType
DictionaryArrayType🏗️DictionaryType | ArrayType
HashtableArrayType🏗️HashtableType | ArrayType

Released under the MIT License. Not affiliated with Sandbox Interactive GmbH.