Peer
About 3 min
Peer
- Full name:
\Hazaar\Warlock\Server\Client\Peer
- Parent class:
\Hazaar\Warlock\Server\Client
Constants
Constant | Visibility | Type | Value |
---|---|---|---|
STATUS_DISCONNECTED | public | 0 | |
STATUS_CONNECTING | public | 1 | |
STATUS_CONNECTED | public | 2 | |
STATUS_NEGOTIATING | public | 3 | |
STATUS_AUTHENTICATING | public | 4 | |
STATUS_STREAMING | public | 5 |
Properties
type
public string $type
status
public int $status
clusterName
public string $clusterName
reconnectTimeout
public static int $reconnectTimeout
- This property is static.
accessKey
private string $accessKey
lastConnectAttempt
private int $lastConnectAttempt
isRemote
private bool $isRemote
Methods
__construct
public __construct(string $clusterName, string $address, int $port = 8000, bool $isRemote = false): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$clusterName | string | |
$address | string | |
$port | int | |
$isRemote | bool |
__destruct
public __destruct(): mixed
process
public process(): void
recv
public recv(string& $buf): void
Parameters:
Parameter | Type | Description |
---|---|---|
$buf | string |
status
public status(): string
connect
public connect(?string $accessKey = null): void
Parameters:
Parameter | Type | Description |
---|---|---|
$accessKey | ?string |
disconnect
Process a stream client disconnect.
public disconnect(): bool
isConnected
public isConnected(): bool
sendEvent
public sendEvent(string $eventID, string $triggerID, mixed $data): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$eventID | string | |
$triggerID | string | |
$data | mixed |
processCommand
protected processCommand(string $command, mixed $payload = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$command | string | |
$payload | mixed |
Inherited methods
__construct
public __construct(resource $stream = null, ?\Hazaar\Map $options = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$stream | resource | |
$options | ?\Hazaar\Map |
parseHeaders
public parseHeaders(string $request, string& $body = ''): string[]
Parameters:
Parameter | Type | Description |
---|---|---|
$request | string | |
$body | string |
createHandshake
protected createHandshake(string $path, string $host, ?string $origin, string $key, string[] $extra_headers = null): string
Parameters:
Parameter | Type | Description |
---|---|---|
$path | string | |
$host | string | |
$origin | ?string | |
$key | string | |
$extra_headers | string[] |
acceptHandshake
protected acceptHandshake(string[] $headers, string[]& $responseHeaders = [], ?string $key = null, string[]& $results = []): bool|int
Parameters:
Parameter | Type | Description |
---|---|---|
$headers | string[] | |
$responseHeaders | string[] | |
$key | ?string | |
$results | string[] |
frame
protected frame(string $payload, ?string $type = null, bool $masked = true): false|string
Parameters:
Parameter | Type | Description |
---|---|---|
$payload | string | |
$type | ?string | |
$masked | bool |
getFrame
protected getFrame(string& $buffer, ?string& $payload = null): bool|int
Parameters:
Parameter | Type | Description |
---|---|---|
$buffer | string | |
$payload | ?string |
checkHost
protected checkHost(string $host): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$host | string |
checkRequestURL
Overridden method from WebSocket class to check the requested WebSocket URL is valid.
protected checkRequestURL(string $url): array<string,int|string>|bool
Parameters:
Parameter | Type | Description |
---|---|---|
$url | string |
checkOrigin
protected checkOrigin(string $origin): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$origin | string |
checkProtocol
protected checkProtocol(string[]|string $protocols): string[]|false
Parameters:
Parameter | Type | Description |
---|---|---|
$protocols | string[]|string |
hexString
protected hexString(string $string): string[]
Parameters:
Parameter | Type | Description |
---|---|---|
$string | string |
getFrameHeaders
private getFrameHeaders(string $frame): (int|string)[]
Parameters:
Parameter | Type | Description |
---|---|---|
$frame | string |
applyMask
private applyMask(string[] $headers, string $payload): false|string
Parameters:
Parameter | Type | Description |
---|---|---|
$headers | string[] | |
$payload | string |
__destruct
public __destruct(): mixed
initiateHandshake
Initiates a WebSocket client handshake.
public initiateHandshake(string $request): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$request | string |
recv
public recv(string& $buf): void
Parameters:
Parameter | Type | Description |
---|---|---|
$buf | string |
send
public send(string $command, mixed $payload = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$command | string | |
$payload | mixed |
disconnect
Process a stream client disconnect.
public disconnect(): bool
commandUnsubscribe
public commandUnsubscribe(string $eventID): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$eventID | string |
commandTrigger
public commandTrigger(string $eventID, mixed $data, bool $echoClient = true): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$eventID | string | |
$data | mixed | |
$echoClient | bool |
sendEvent
public sendEvent(string $eventID, string $triggerID, mixed $data): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$eventID | string | |
$triggerID | string | |
$data | mixed |
ping
public ping(): bool
pong
public pong(): void
httpResponse
Generate an HTTP response message.
protected httpResponse(int $code, string $body = null, string[] $headers = []): string
Parameters:
Parameter | Type | Description |
---|---|---|
$code | int | HTTP response code |
$body | string | The response body |
$headers | string[] | Additional headers |
write
protected write(string $frame): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$frame | string |
processFrame
Processes a client data frame.
protected processFrame(string& $frameBuffer): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$frameBuffer | string |
processCommand
protected processCommand(string $command, mixed $payload = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$command | string | |
$payload | mixed |
commandAuthorise
protected commandAuthorise(\stdClass $payload, bool $acknowledge = true): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$payload | \stdClass | |
$acknowledge | bool |
commandStatus
protected commandStatus(?\stdClass $payload = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$payload | ?\stdClass |
commandSubscribe
protected commandSubscribe(string $eventID, array<string,mixed> $filter = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$eventID | string | |
$filter | array<string,mixed> |
commandLog
protected commandLog(\stdClass $payload): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$payload | \stdClass |
initiateWebSocketsHandshake
Initiates a WebSocket client handshake.
private initiateWebSocketsHandshake(array<string,string> $headers): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$headers | array<string,string> |
initiateRESTHandshake
Initiates a REST client handshake.
private initiateRESTHandshake(array<string,string> $headers, string $body): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$headers | array<string,string> | |
$body | string |
Automatically generated on 2024-11-14