class Client

Class Client

Properties

protected string $endpoint
protected string $serverHost
protected int $serverPort
protected resource $socket
protected bool $connected
protected string $sessionId
protected string $origin
protected LoggerInterface $logger
protected bool $closing
protected bool $secured
protected string $target

Methods

__construct(string $host, int|string $port, bool $secured = false, string $origin = null)

No description

setLogger(LoggerInterface $logger = null)

No description

setAuthenticationToken()

No description

string
connect(string $target = '/')

No description

string
upgradeProtocol(string $target)

No description

verifyResponse($response)

No description

string
read()

Read the buffer and return the oldest event in stack.

bool
disconnect()

Disconnect.

$this|Client
send($data, $opcode = WebsocketPayload::OPCODE_TEXT, $masked = true)

Send message to the websocket.

prefix(string $prefix, string $uri)

Establish a prefix on server.

call(mixed $procUri, mixed $arguments = [])

Call a procedure on server.

publish(string $topicUri, string $payload, array|string $exclude = [], array|string $eligible = [])

The client will send an event to all clients connected to the server who have subscribed to the topicURI.

event(string $topicUri, string $payload)

Subscribers receive PubSub events published by subscribers via the EVENT message. The EVENT message contains the topicURI, the topic under which the event was published, and event, the PubSub event payload.

string
generateKey(int $length = 16)

No description

bool
isConnected()

No description

Details

at line 55
__construct(string $host, int|string $port, bool $secured = false, string $origin = null)

Parameters

string $host
int|string $port
bool $secured
string $origin

at line 78
setLogger(LoggerInterface $logger = null)

Parameters

LoggerInterface $logger

at line 86
setAuthenticationToken()

at line 99
string connect(string $target = '/')

Parameters

string $target

Return Value

string

Exceptions

BadResponseException
WebsocketException

at line 128
protected string upgradeProtocol(string $target)

Parameters

string $target

Return Value

string

Exceptions

WebsocketException

at line 157
protected verifyResponse($response)

Parameters

$response

Exceptions

BadResponseException

at line 175
protected string read()

Read the buffer and return the oldest event in stack.

at line 199
bool disconnect()

Disconnect.

Return Value

bool

at line 235
protected $this|Client send($data, $opcode = WebsocketPayload::OPCODE_TEXT, $masked = true)

Send message to the websocket.

Parameters

$data
$opcode
$masked

Return Value

$this|Client

at line 261
prefix(string $prefix, string $uri)

Establish a prefix on server.

Parameters

string $prefix
string $uri

See also

http://wamp.ws/spec#prefix_message

at line 277
call(mixed $procUri, mixed $arguments = [])

Call a procedure on server.

Parameters

mixed $procUri
mixed $arguments

See also

http://wamp.ws/spec#call_message

at line 297
publish(string $topicUri, string $payload, array|string $exclude = [], array|string $eligible = [])

The client will send an event to all clients connected to the server who have subscribed to the topicURI.

Parameters

string $topicUri mixed $topicUri
string $payload mixed $payload
array|string $exclude
array|string $eligible

See also

http://wamp.ws/spec#publish_message

at line 315
event(string $topicUri, string $payload)

Subscribers receive PubSub events published by subscribers via the EVENT message. The EVENT message contains the topicURI, the topic under which the event was published, and event, the PubSub event payload.

Parameters

string $topicUri
string $payload

at line 327
protected string generateKey(int $length = 16)

Parameters

int $length

Return Value

string

at line 341
bool isConnected()

Return Value

bool