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 34
__construct()

No description

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

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

No description

Parameters

ConfiguresSocketConnection $connection
ProvidesRequestData $request

Return Value

int SocketId

Exceptions

TimedoutException
WriteFailedException
ConnectException

at line 95
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 119
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 148
ProvidesResponseData readResponse(int $socketId, int|null $timeoutMs = null)

No description

Parameters

int $socketId
int|null $timeoutMs

Return Value

ProvidesResponseData

Exceptions

Throwable

at line 169
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 195
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 255
bool hasUnhandledResponses()

No description

Return Value

bool

at line 263
bool hasResponse(int $socketId)

No description

Parameters

int $socketId

Return Value

bool

Exceptions

ReadFailedException

at line 272
array getSocketIdsHavingResponse()

No description

Return Value

array

Exceptions

ReadFailedException

at line 310
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 339
Generator readReadyResponses(int|null $timeoutMs = null)

No description

Parameters

int|null $timeoutMs

Return Value

Generator

Exceptions

ReadFailedException

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

No description

Parameters

int $socketId
int|null $timeoutMs

Return Value

void

Exceptions

ReadFailedException

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

No description

Parameters

int|null $timeoutMs
int ...$socketIds

Return Value

void

Exceptions

ReadFailedException

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

No description

Parameters

int|null $timeoutMs

Return Value

void

Exceptions

ReadFailedException