Client
Client
Base server-side client connection abstraction.
class Client extends \Hazaar\Warlock\Server\WebSockets implements \Hazaar\Warlock\Interface\ClientProperties
address
public string $addressport
public int $portid
Unique client ID assigned by the server.
public string $idtype
Current logical client type.
public ClientType $type = 'ClientType'stream
public mixed $streamclosing
Indicates websocket close handshake state.
public bool $closingframeBuffer
public string $frameBufferpayloadBuffer
public string $payloadBuffername
Human-readable client name label.
public string $nameusername
public string $usernamesince
Connection establishment timestamp.
public int $sincelastContact
Last contact timestamp from client traffic.
public int $lastContactping
public array $ping = array (
'attempts' => 0,
'last' => 0,
'retry' => 5,
'retries' => 3,
)offset
Any detected time offset. This doesn't need to be exact so we don't bother worrying about latency.
public int $offsetsubscriptions
This is an array of eventID and stream pairs.
public array $subscriptionsstart
Process start timestamp inherited from server runtime.
protected int $startmain
Owning server instance.
protected Main $mainMethods
__construct
public __construct(Main $main, mixed $stream, ?array $options): voidParameters
| Parameter | Type | Description |
|---|---|---|
$main | Main | |
$stream | mixed | |
$options | array |
__destruct
public __destruct(): voidgetTypeFromHandshake
public getTypeFromHandshake(string $request): ClientTypeParameters
| Parameter | Type | Description |
|---|---|---|
$request | string |
initiateHandshake
Initiates the handshake for an agent client.
public initiateHandshake(string $request, array $headers): voidParameters
| Parameter | Type | Description |
|---|---|---|
$request | string | the request string from the client |
$headers | array | reference to an array where headers will be stored |
recv
public recv(string $buf): voidParameters
| Parameter | Type | Description |
|---|---|---|
$buf | string |
send
public send(PacketType $command, mixed $payload): boolParameters
| Parameter | Type | Description |
|---|---|---|
$command | PacketType | |
$payload | mixed |
disconnect
Process a stream client disconnect.
public disconnect(): boolauthenticated
public authenticated(): boolcommandUnsubscribe
public commandUnsubscribe(string $eventID): boolParameters
| Parameter | Type | Description |
|---|---|---|
$eventID | string |
commandTrigger
public commandTrigger(string $eventID, mixed $data, bool $echoClient = true): boolParameters
| Parameter | Type | Description |
|---|---|---|
$eventID | string | |
$data | mixed | |
$echoClient | bool |
sendEvent
public sendEvent(string $eventID, string $triggerID, mixed $data): boolParameters
| Parameter | Type | Description |
|---|---|---|
$eventID | string | |
$triggerID | string | |
$data | mixed |
ping
public ping(): boolpong
public pong(): voidcheckRequestURL
Overridden method from WebSocket class to check the requested WebSocket URL is valid.
protected checkRequestURL(string $url, bool $): voidParameters
| Parameter | Type | Description |
|---|---|---|
$url | string | |
$ | bool |
httpResponse
Generate an HTTP response message.
protected httpResponse(int $code, ?string $body, array $headers): stringParameters
| Parameter | Type | Description |
|---|---|---|
$code | int | HTTP response code |
$body | string | The response body |
$headers | array | Additional headers |
write
protected write(string $frame): boolParameters
| Parameter | Type | Description |
|---|---|---|
$frame | string |
processFrame
Processes a client data frame.
protected processFrame(string $frameBuffer): mixedParameters
| Parameter | Type | Description |
|---|---|---|
$frameBuffer | string |
processCommand
protected processCommand(PacketType $command, mixed $payload): boolParameters
| Parameter | Type | Description |
|---|---|---|
$command | PacketType | |
$payload | mixed |
commandAuthenticate
protected commandAuthenticate(\stdClass $payload, bool $service): boolParameters
| Parameter | Type | Description |
|---|---|---|
$payload | \stdClass | |
$service | bool |
commandStatus
protected commandStatus(?\stdClass $payload): boolParameters
| Parameter | Type | Description |
|---|---|---|
$payload | \stdClass |
commandSubscribe
protected commandSubscribe(string $eventID, ?array $filter): boolParameters
| Parameter | Type | Description |
|---|---|---|
$eventID | string | |
$filter | array |
commandLog
protected commandLog(\stdClass $payload): boolParameters
| Parameter | Type | Description |
|---|---|---|
$payload | \stdClass |
initiateWebSocketsHandshake
Initiates a WebSocket client handshake.
private initiateWebSocketsHandshake(array $headers): boolParameters
| Parameter | Type | Description |
|---|---|---|
$headers | array |
initiateRESTHandshake
Initiates a REST client handshake.
private initiateRESTHandshake(array $headers, string $body): boolParameters
| Parameter | Type | Description |
|---|---|---|
$headers | array | |
$body | string |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:25 +0000