Protocol
Protocol
Hazaar Application Protocol Class
class ProtocolThe Application Protocol is a simple protocol developed to allow communication between parts of the Hazaar framework over the wire or other IO interfaces. It allows common information to be encoded/decoded between endpoints.
Properties
sid
Server identifier included in encoded packets.
private string $sidType: string
lastError
Last decode/validation error.
private string $lastErrorType: string
encoded
Whether payloads are base64-encoded over the transport.
private bool $encoded = trueType: bool
Methods
__construct
public __construct(string $sid, bool $encoded = true): voidParameters
| Parameter | Type | Description |
|---|---|---|
$sid | string | server identifier |
$encoded | bool | whether packets are base64-wrapped |
getLastError
Returns the most recent protocol error message.
public getLastError(): stringReturns: string
encoded
Returns whether packet encoding is enabled.
public encoded(): boolReturns: bool
encode
Encodes a packet type and optional payload for transport.
public encode(PacketType $type, mixed $payload): false|stringReturns: false|string
Parameters
| Parameter | Type | Description |
|---|---|---|
$type | Hazaar\Warlock\Enum\PacketType | |
$payload | mixed |
decode
Decodes a raw packet string and extracts type/payload/timestamp.
public decode(string $packet, mixed $payload, ?int $time): false|PacketType|nullReturns: false|Hazaar\Warlock\Enum\PacketType|null
Parameters
| Parameter | Type | Description |
|---|---|---|
$packet | string | raw packet buffer |
$payload | mixed | output payload |
$time | int | output packet timestamp |
error
Stores and returns a protocol error sentinel.
private error(string $msg): falseReturns: false
Parameters
| Parameter | Type | Description |
|---|---|---|
$msg | string |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:17 +0000