Service
About 2 min
Service
- Full name:
\Hazaar\Warlock\Server\Client\Service
- Parent class:
\Hazaar\Warlock\Server\Client
Properties
name
public string $name
address
public ?string $address
port
public int $port
serviceStatus
public \stdClass $serviceStatus
Methods
frame
protected frame(string $payload, ?string $type = null, bool $masked = true): false|string
Parameters:
Parameter | Type | Description |
---|---|---|
$payload | string | |
$type | ?string | |
$masked | bool |
processFrame
Processes a client data frame.
protected processFrame(string& $frameBuffer): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$frameBuffer | string |
commandStatus
protected commandStatus(?\stdClass $payload = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$payload | ?\stdClass |
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