Socket
Socket
class Socket extends \Hazaar\Warlock\Protocol\WebSockets implements \Hazaar\Warlock\Interface\ConnectionExtends: Hazaar\Warlock\Protocol\WebSockets
Implements: Hazaar\Warlock\Interface\Connection
Properties
bytesReceived
Total bytes received from the remote endpoint.
public int $bytesReceivedType: int
socketLastError
Last socket error code encountered.
public int $socketLastErrorType: int
host
Remote server host name/address.
protected string $host = '127.0.0.1'Type: string
port
Remote server TCP port.
protected int $port = 13080Type: int
id
Client identifier used in handshake URL.
protected string $idType: string
key
WebSocket handshake key.
protected string $keyType: string
socket
Underlying PHP socket resource.
protected false|\Socket $socketType: false|Socket
connected
Internal connected flag.
protected bool $connectedType: bool
protocol
Protocol encoder/decoder used for payload packets.
protected Protocol $protocolType: Hazaar\Warlock\Protocol
frameBuffer
public string $frameBufferType: string
payloadBuffer
public string $payloadBufferType: string
closing
Indicates a close handshake is in progress.
protected bool $closingType: bool
headers
protected array $headersType: array
Methods
__construct
public __construct(Protocol $protocol, ?string $guid, array $headers): voidParameters
| Parameter | Type | Description |
|---|---|---|
$protocol | Hazaar\Warlock\Protocol | |
$guid | string | |
$headers | array |
__destruct
public __destruct(): voidconfigure
Applies runtime socket connection settings.
public configure(array $config): voidReturns: void
The array $config signature is dictated by the Connection interface; internally it is normalised into a typed Options instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
$config | array |
addHeaders
Add custom headers to the WebSocket handshake request.
public addHeaders(array $headers): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$headers | array | an associative array of header names and values to add to the handshake request |
getHost
Get the host of the Warlock server.
public getHost(): stringReturns: string
getPort
Get the port of the Warlock server.
public getPort(): intReturns: int
connect
Connect to the Warlock server.
public connect(): boolReturns: bool
getLastSocketError
public getLastSocketError(bool $asString): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$asString | bool |
disconnect
public disconnect(): boolReturns: bool
connected
public connected(): boolReturns: bool
send
public send(PacketType $command, mixed $payload): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$command | Hazaar\Warlock\Enum\PacketType | |
$payload | mixed |
recv
public recv(mixed $payload, int $tvSec = 3, int $tvUsec): bool|PacketType|nullReturns: bool|Hazaar\Warlock\Enum\PacketType|null
Parameters
| Parameter | Type | Description |
|---|---|---|
$payload | mixed | |
$tvSec | int | |
$tvUsec | int |
processFrame
protected processFrame(?string $frameBuffer): bool|stringReturns: bool|string
Parameters
| Parameter | Type | Description |
|---|---|---|
$frameBuffer | string |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:17 +0000