v16

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Header struct {
	ID   uint8         `json:"id"`   // Parameter identifier (application-specific)
	Type ParameterType `json:"type"` // Protocol16 type code indicating how to decode the value
}

Header represents the parameter header containing the parameter ID and type. This appears at the beginning of each serialized parameter.

type Parameter

type Parameter struct {
	Header `json:"header"`
	Value  `json:"value"`
}

Parameters represents a complete Photon Protocol parameter with its header and decoded value. The Value field contains the decoded data according to the Type specified in the Header.

func (Parameter) ArrayValue

func (p Parameter) ArrayValue() iter.Seq2[int, any]

func (Parameter) BooleanArrayValue

func (p Parameter) BooleanArrayValue() iter.Seq2[int, bool]

func (Parameter) BooleanValue

func (p Parameter) BooleanValue() (bool, bool)

func (Parameter) ByteArrayValue

func (p Parameter) ByteArrayValue() iter.Seq2[int, byte]

func (Parameter) DictionaryValue

func (p Parameter) DictionaryValue() iter.Seq2[any, any]

func (Parameter) Float32ArrayValue

func (p Parameter) Float32ArrayValue() iter.Seq2[int, float32]

func (Parameter) Float32Value

func (p Parameter) Float32Value() (float32, bool)

func (Parameter) Float64Value

func (p Parameter) Float64Value() (float64, bool)

func (Parameter) ID

func (p Parameter) ID() uint8

func (Parameter) Int8ArrayValue

func (p Parameter) Int8ArrayValue() iter.Seq2[int, int8]

func (Parameter) Int16ArrayValue

func (p Parameter) Int16ArrayValue() iter.Seq2[int, int16]

func (Parameter) Int32ArrayValue

func (p Parameter) Int32ArrayValue() iter.Seq2[int, int32]

func (Parameter) Int64ArrayValue

func (p Parameter) Int64ArrayValue() iter.Seq2[int, int64]

func (Parameter) IntValue

func (p Parameter) IntValue() (int64, bool)

func (Parameter) MarshalJSON

func (p Parameter) MarshalJSON() ([]byte, error)

func (*Parameter) ParseInto added in v1.0.0

func (p *Parameter) ParseInto(reader *reader.Reader, hooks *hooks.Hooks[Parameter], dest *Parameter) error

Parse reads a complete parameter from the reader. Format: Header (1 byte ID + 1 byte Type), followed by the typed value.

The function first reads the parameter header to determine the parameter ID and type code, then decodes the value according to that type using the Protocol16 decoder.

Returns a Parameters struct containing the ID, Type, and decoded Value, or an error if parsing fails.

Example usage:

param, err := parameters.Parse(reader)
if err != nil {
    return err
}
fmt.Printf("Parameter %d has value: %v\n", param.ID, param.Value)

func (Parameter) String

func (p Parameter) String() string

func (Parameter) StringArrayValue

func (p Parameter) StringArrayValue() iter.Seq2[int, string]

func (Parameter) StringValue

func (p Parameter) StringValue() (string, bool)

type ParameterType

type ParameterType uint8

Type represents a Photon Protocol16 type code. Each type code indicates how the following bytes should be interpreted.

const (
	UnknownType           ParameterType = 0x00 // Unknown or unsupported type
	NilType               ParameterType = 0x2a // Null/nil value
	DictionaryType        ParameterType = 0x44 // Dictionary with fixed key/value types
	StringArrayType       ParameterType = 0x61 // Array of strings
	Int8Type              ParameterType = 0x62 // 8-bit signed integer
	Custom                ParameterType = 0x63 // Custom serialized object
	DoubleType            ParameterType = 0x64 // Alias for Float64Type
	EventDateType         ParameterType = 0x65 // Event date/time
	Float32Type           ParameterType = 0x66 // 32-bit floating point
	Float64Type           ParameterType = 0x67 // 64-bit floating point
	HashTableType         ParameterType = 0x68 // Hashtable with mixed key/value types
	Int32Type             ParameterType = 0x69 // 32-bit signed integer
	Int16Type             ParameterType = 0x6b // 16-bit signed integer
	Int64Type             ParameterType = 0x6c // 64-bit signed integer
	Int32ArrayType        ParameterType = 0x6e // Array of 32-bit integers
	BooleanType           ParameterType = 0x6f // Boolean (0x00=false, 0x01=true)
	OperationResponseType ParameterType = 0x70 // Operation response message
	OperationRequestType  ParameterType = 0x71 // Operation request message
	StringType            ParameterType = 0x73 // UTF-8 string with uint16 length prefix
	Int8ArrayType         ParameterType = 0x78 // Array of 8-bit integers
	ArrayType             ParameterType = 0x79 // Generic typed array
	ObjectArrayType       ParameterType = 0x7a // Array of serialized objects
)

Photon Protocol16 type codes. These constants define the binary type codes used in Photon's serialization format.

type ReliableHeaderParameterCountV16

type ReliableHeaderParameterCountV16 struct{}

func (ReliableHeaderParameterCountV16) Count

type Value

type Value struct {
	Kind    ParameterType `json:"kind"`
	KeyType ParameterType `json:"key_type"`
	ValType ParameterType `json:"val_type"`

	Num  uint64 `json:"num"`
	Blob []byte `json:"blob,omitempty"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL