class Client

Methods

__construct()

No description

int
sendAsyncRequest(ConfiguresSocketConnection $connection, ProvidesRequestData $request)

No description

tryRequest(ConfiguresSocketConnection $connection, ProvidesRequestData $request, int $maxTries = 5)

Sends the request like sendRequest(), but retries on another socket if writing the request to the socket failed.

int
tryAsyncRequest(ConfiguresSocketConnection $connection, ProvidesRequestData $request, int $maxTries = 5)

Sends the request like sendAsyncRequest(), but retries on another socket if writing the request to the socket failed.

readResponse(int $socketId, int|null $timeoutMs = null)

No description

void
waitForResponse(int $socketId, int|null $timeoutMs = null)

Waits until the response is received and notifies the response callbacks of the request.

void
waitForResponses(int|null $timeoutMs = null)

Waits until all responses are received and notifies the callbacks of their requests.

bool
hasUnhandledResponses()

No description

bool
hasResponse(int $socketId)

No description

array
getSocketIdsHavingResponse()

No description

readResponses(int|null $timeoutMs = null, int ...$socketIds)

Reads the responses of the given sockets in the given order. Unknown socket IDs are skipped.

readReadyResponses(int|null $timeoutMs = null)

No description

void
handleResponse(int $socketId, int|null $timeoutMs = null)

No description

void
handleResponses(int|null $timeoutMs = null, int ...$socketIds)

No description

void
handleReadyResponses(int|null $timeoutMs = null)

No description

Details

at line 33
__construct()

No description

at line 46
ProvidesResponseData sendRequest(ConfiguresSocketConnection $connection, ProvidesRequestData $request)

at line 63
int sendAsyncRequest(ConfiguresSocketConnection $connection, ProvidesRequestData $request)

No description

Parameters

ConfiguresSocketConnection $connection
ProvidesRequestData $request

Return Value

int SocketId

Exceptions

TimedoutException
WriteFailedException
ConnectException

at line 94
ProvidesResponseData tryRequest(ConfiguresSocketConnection $connection, ProvidesRequestData $request, int $maxTries = 5)

Sends the request like sendRequest(), but retries on another socket if writing the request to the socket failed.

Failures while reading the response are not retried, because the request may already have been processed.

Parameters

ConfiguresSocketConnection $connection
ProvidesRequestData $request
int $maxTries

Maximum number of attempts to send the request

Return Value

ProvidesResponseData

Exceptions

Throwable
TimedoutException
WriteFailedException
ConnectException
InvalidArgumentException

at line 118
int tryAsyncRequest(ConfiguresSocketConnection $connection, ProvidesRequestData $request, int $maxTries = 5)

Sends the request like sendAsyncRequest(), but retries on another socket if writing the request to the socket failed.

Parameters

ConfiguresSocketConnection $connection
ProvidesRequestData $request
int $maxTries

Maximum number of attempts to send the request

Return Value

int SocketId

Exceptions

TimedoutException
WriteFailedException
ConnectException
InvalidArgumentException

at line 147
ProvidesResponseData readResponse(int $socketId, int|null $timeoutMs = null)

No description

Parameters

int $socketId
int|null $timeoutMs

Return Value

ProvidesResponseData

Exceptions

Throwable

at line 168
void waitForResponse(int $socketId, int|null $timeoutMs = null)

Waits until the response is received and notifies the response callbacks of the request.

If there is no response within the timeout (default: the read/write timeout of the connection), the failure callbacks are notified with a TimedoutException.

Parameters

int $socketId
int|null $timeoutMs

Return Value

void

Exceptions

ReadFailedException

at line 194
void waitForResponses(int|null $timeoutMs = null)

Waits until all responses are received and notifies the callbacks of their requests.

Requests without response within the timeout (default: the read/write timeout of their connection) notify their failure callbacks with a TimedoutException.

Parameters

int|null $timeoutMs

Return Value

void

Exceptions

ReadFailedException
Throwable

at line 254
bool hasUnhandledResponses()

No description

Return Value

bool

at line 262
bool hasResponse(int $socketId)

No description

Parameters

int $socketId

Return Value

bool

Exceptions

ReadFailedException

at line 271
array getSocketIdsHavingResponse()

No description

Return Value

array

Exceptions

ReadFailedException

at line 317
Generator readResponses(int|null $timeoutMs = null, int ...$socketIds)

Reads the responses of the given sockets in the given order. Unknown socket IDs are skipped.

If a response cannot be read, its exception is thrown and the remaining responses are not read.

Parameters

int|null $timeoutMs
int ...$socketIds

Return Value

Generator

Exceptions

ReadFailedException
TimedoutException
WriteFailedException

at line 346
Generator readReadyResponses(int|null $timeoutMs = null)

No description

Parameters

int|null $timeoutMs

Return Value

Generator

Exceptions

ReadFailedException

at line 359
void handleResponse(int $socketId, int|null $timeoutMs = null)

No description

Parameters

int $socketId
int|null $timeoutMs

Return Value

void

Exceptions

ReadFailedException

at line 372
void handleResponses(int|null $timeoutMs = null, int ...$socketIds)

No description

Parameters

int|null $timeoutMs
int ...$socketIds

Return Value

void

Exceptions

ReadFailedException

at line 383
void handleReadyResponses(int|null $timeoutMs = null)

No description

Parameters

int|null $timeoutMs

Return Value

void

Exceptions

ReadFailedException