Peer
Peer
Server-side client wrapper for cluster peer connections.
class Peer extends \Hazaar\Warlock\Server\ClientExtends: Hazaar\Warlock\Server\Client
Properties
type
Fixed client type for cluster peers.
public ClientType $type = 'ClientType'Type: Hazaar\Warlock\Enum\ClientType
peerStatus
Current peer connection state.
public PeerStatus $peerStatus = 'PeerStatus'Type: Hazaar\Warlock\Enum\PeerStatus
identityConfirmed
Whether this peer's real cluster identity has been confirmed via PEERINFO (as opposed
public bool $identityConfirmedType: bool
to still carrying the meaningless per-socket default $name from Client::__construct()). Set by Cluster::processCommand() once it re-keys this peer under its real name.
reconnectTimeout
Minimum seconds between reconnect attempts.
private int $reconnectTimeout = 15Type: int
lastConnectAttempt
Timestamp of the most recent connect attempt.
private int $lastConnectAttemptType: int
Methods
__construct
public __construct(Main $main, mixed $stream, ?array $options): voidParameters
| Parameter | Type | Description |
|---|---|---|
$main | Hazaar\Warlock\Server\Main | server runtime instance |
$stream | mixed | existing stream resource, if any |
$options | array | peer/client options |
__destruct
Emits peer destruction diagnostics.
public __destruct(): voidinitiateHandshake
Handles websocket handshake initiation for inbound peer connections.
public initiateHandshake(string $request, array $headers): boolReturns: bool
The peer must present the cluster access key (and the cluster name, when one is configured) before the WebSocket upgrade is accepted, so a rejected peer never sees a 101.
Parameters
| Parameter | Type | Description |
|---|---|---|
$request | string | |
$headers | array |
process
Advances peer connection state machine and IO handling.
public process(): voidReturns: void
recv
Processes incoming data according to current peer status phase.
public recv(string $buf): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$buf | string |
status
Returns human-readable peer status text.
public status(): stringReturns: string
connect
Initiates asynchronous TCP connection to configured peer endpoint.
public connect(): boolReturns: bool
disconnect
public disconnect(): boolReturns: bool
isConnected
public isConnected(): boolReturns: bool
sendEvent
public sendEvent(string $eventID, string $triggerID, mixed $data): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$eventID | string | |
$triggerID | string | |
$data | mixed |
processCommand
protected processCommand(PacketType $command, mixed $payload): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$command | Hazaar\Warlock\Enum\PacketType | |
$payload | mixed |
announceIdentity
Announces this server's own identity to the peer at the other end of this connection.
private announceIdentity(): voidReturns: void
Called by both the dialer and the acceptor as soon as their own side of the handshake completes, making identity exchange symmetric - see Cluster::processCommand()'s PEERINFO handling, which is what re-keys the corresponding Peer object on the receiving end.
Generated by Hazaar API Doc Generator on Thu, 22 Oct 2026 05:05:31 +0000