Documentation
¶
Index ¶
Constants ¶
View Source
const COMMAND_HEADER_SIZE = 12
COMMAND_HEADER_SIZE is the size in bytes of a command header (12 bytes).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Acknowledge ¶ added in v1.0.0
type AsyncHooks ¶
type AsyncHooks[P ParameterView] struct { OnSession chan Session[P] OnCommand chan Command[P] OnParameter chan P }
type Command ¶
type Command[P ParameterView] struct { CommandHeader `json:"header"` UnreliablePayload Reliable[P] `json:"unreliable_payload"` ReliablePayload Reliable[P] `json:"reliable_payload"` ReliableFragmentPayload Fragment `json:"reliable_fragment_payload"` AcknowledgePayload Acknowledge `json:"acknowledge_payload"` ConnectPayload Connect `json:"connect_payload"` UnknownPayload UnknownPayload `json:"unknown_payload"` PingPayload struct{} `json:"ping_payload"` DisconnectPayload struct{} `json:"disconnect_payload"` }
Command represents a Photon command with its header and payload data. To gain in performance we use a union of single struct for all command types.
type CommandHeader ¶
type CommandType ¶
type CommandType uint8
CommandType represents a Photon Protocol command type.
const ( AcknowledgeCommand CommandType = 0x01 ConnectCommand CommandType = 0x02 VerifyConnectCommand CommandType = 0x03 DisconnectCommand CommandType = 0x04 PingCommand CommandType = 0x05 SendReliableCommand CommandType = 0x06 SendUnreliableCommand CommandType = 0x07 SendReliableFragmentCommand CommandType = 0x08 )
type Config ¶ added in v1.0.0
type Config struct {
SkipUnknownPayloads bool `json:"skip_unknown_payloads"`
SkipParameterParsing bool `json:"skip_parameter_parsing"`
SkipCommands map[CommandType]bool `json:"skip_commands"`
SkipTargetEventCodes map[MessageType]bool `json:"skip_target_event_codes"`
}
type Connect ¶ added in v1.0.0
type Connect struct {
Mtu uint32 `json:"mtu"`
WindowSize uint32 `json:"window_size"`
ChannelCount uint32 `json:"channel_count"`
IncomingBandwidth uint32 `json:"incoming_bandwidth"`
OutgoingBandwidth uint32 `json:"outgoing_bandwidth"`
DisconnectThrottle uint32 `json:"disconnect_throttle"`
PacketThrottleAcceleration uint32 `json:"packet_throttle_acceleration"`
PacketThrottleDeceleration uint32 `json:"packet_throttle_deceleration"`
}
type Fragment ¶
type Fragment struct {
ID uint32 `json:"id"`
Count uint32 `json:"count"`
Index uint32 `json:"index"`
Size uint32 `json:"size"`
Offset uint32 `json:"offset"`
Data []byte `json:"data"`
}
Some commands data are fragmented, this struct represents the fragment metadata.
type HookOptions ¶
type HookOptions struct {
Size uint16
}
type MessageType ¶ added in v1.0.0
type MessageType uint8
const ( OperationRequest MessageType = 0x02 // Client requests an operation OperationResponse MessageType = 0x07 // Server responds to an operation OtherOperationResponse MessageType = 0x03 // Alternative response format EventDataType MessageType = 0x04 // Server sends an event to client ExchangeKeys MessageType = 0x06 // Key exchange for encryption )
type ParameterView ¶
type ParameterView interface {
ID() uint8
Float32ArrayValue() iter.Seq2[int, float32]
Int32ArrayValue() iter.Seq2[int, int32]
Int64ArrayValue() iter.Seq2[int, int64]
Int16ArrayValue() iter.Seq2[int, int16]
Int8ArrayValue() iter.Seq2[int, int8]
ByteArrayValue() iter.Seq2[int, byte]
StringArrayValue() iter.Seq2[int, string]
BooleanArrayValue() iter.Seq2[int, bool]
ArrayValue() iter.Seq2[int, any]
BooleanValue() (bool, bool)
StringValue() (string, bool)
Float32Value() (float32, bool)
Float64Value() (float64, bool)
IntValue() (int64, bool)
MarshalJSON() ([]byte, error)
}
type Reliable ¶ added in v1.0.0
type Reliable[P ParameterView] struct { ReliableHeader `json:"reliable_header"` Parameters []P `json:"parameters"` }
type ReliableHeader ¶ added in v1.0.0
type ReliableHeader struct {
Signature uint8 `json:"signature"` // Message signature (typically 0xF3)
Type MessageType `json:"type"` // Message type (operation, event, etc.)
EventCode uint8 `json:"event_code"` // Operation/event code (application-specific)
ParameterCount int `json:"parameter_count"` // Number of parameters following this header
}
type Session ¶
type Session[P ParameterView] struct { SessionHeader `json:"header"` Commands []Command[P] `json:"commands"` }
Session represents a complete Photon session packet with its header and commands. A session packet can contain multiple commands that will be processed sequentially.
type SessionHeader ¶ added in v1.0.0
type SessionHeader struct {
PeerID uint16 `json:"peer_id"` // Peer identifier for this connection
CRCEnabled uint8 `json:"crc_enabled"` // CRC checksum flag (0 = disabled, 1 = enabled)
CommandCount uint8 `json:"command_count"` // Number of commands following this header
Timestamp uint32 `json:"timestamp"` // Timestamp in milliseconds
Challenge int32 `json:"challenge"` // Challenge value for connection verification
}
type SyncHooks ¶
type SyncHooks[P ParameterView] struct { OnSession func(Session[P]) OnCommand func(Command[P]) OnEvents map[MessageType]func(Reliable[P]) OnParameter func(P) }
type UnknownPayload ¶
type UnknownPayload struct {
Raw []byte `json:"raw"`
Kind CommandType `json:"kind"`
}
Click to show internal directories.
Click to hide internal directories.