Documentation
¶
Index ¶
- type Header
- type Parameter
- func (p Parameter) ArrayValue() iter.Seq2[int, any]
- func (p Parameter) BooleanArrayValue() iter.Seq2[int, bool]
- func (p Parameter) BooleanValue() (bool, bool)
- func (p Parameter) ByteArrayValue() iter.Seq2[int, byte]
- func (p Parameter) DictionaryValue() iter.Seq2[any, any]
- func (p Parameter) Float32ArrayValue() iter.Seq2[int, float32]
- func (p Parameter) Float32Value() (float32, bool)
- func (p Parameter) Float64Value() (float64, bool)
- func (p Parameter) ID() uint8
- func (p Parameter) Int8ArrayValue() iter.Seq2[int, int8]
- func (p Parameter) Int16ArrayValue() iter.Seq2[int, int16]
- func (p Parameter) Int32ArrayValue() iter.Seq2[int, int32]
- func (p Parameter) Int64ArrayValue() iter.Seq2[int, int64]
- func (p Parameter) IntValue() (int64, bool)
- func (p Parameter) MarshalJSON() ([]byte, error)
- func (p *Parameter) ParseInto(reader *reader.Reader, hooks *hooks.Hooks[Parameter], dest *Parameter) error
- func (p Parameter) String() string
- func (p Parameter) StringArrayValue() iter.Seq2[int, string]
- func (p Parameter) StringValue() (string, bool)
- type ParameterType
- type ReliableHeaderParameterCountV16
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Header ¶
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 ¶
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) BooleanValue ¶
func (Parameter) Float32Value ¶
func (Parameter) Float64Value ¶
func (Parameter) MarshalJSON ¶
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) StringValue ¶
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{}
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
}