Protocol
Less than 1 minute
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 $sidlastError
Last decode/validation error.
private string $lastErrorencoded
Whether payloads are base64-encoded over the transport.
private bool $encoded = trueMethods
__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(): stringencoded
Returns whether packet encoding is enabled.
public encoded(): boolencode
Encodes a packet type and optional payload for transport.
public encode(PacketType $type, mixed $payload): stringParameters
| Parameter | Type | Description |
|---|---|---|
$type | PacketType | |
$payload | mixed |
decode
Decodes a raw packet string and extracts type/payload/timestamp.
public decode(string $packet, mixed $payload, ?int $time): nullParameters
| 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): falseParameters
| Parameter | Type | Description |
|---|---|---|
$msg | string |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:25 +0000