SocketIpcHub
in package
implements
IpcHub
uses
ForbidCloning, ForbidSerialization
FinalYes
Table of Contents
Interfaces
Constants
Properties
- $accept : callable(): void
- $clientsByKey : LocalCache<string|int, ResourceSocket>
- $keyLength : int
- $queued : bool
- $server : ServerSocket
- $uri : non-empty-string
- $waitingByKey : array<string, DeferredFuture>
Methods
- __construct() : mixed
- __destruct() : mixed
- __serialize() : never
- __unserialize() : never
- accept() : ResourceSocket
- close() : void
- Closes the resource, marking it as unusable.
- generateKey() : non-empty-string
- getUri() : non-empty-string
- isClosed() : bool
- Returns whether this resource has been closed.
- onClose() : void
- Registers a callback that is invoked when this resource is closed.
- __clone() : mixed
Constants
DEFAULT_KEY_LENGTH
public
mixed
DEFAULT_KEY_LENGTH
= 64
DEFAULT_KEY_RECEIVE_TIMEOUT
public
mixed
DEFAULT_KEY_RECEIVE_TIMEOUT
= 5
Properties
$accept read-only
private
callable(): void
$accept
$clientsByKey
private
LocalCache<string|int, ResourceSocket>
$clientsByKey
$keyLength read-only
private
int
$keyLength
= self::DEFAULT_KEY_LENGTH
$queued
private
bool
$queued
= false
$server read-only
private
ServerSocket
$server
$uri read-only
private
non-empty-string
$uri
$waitingByKey
private
array<string, DeferredFuture>
$waitingByKey
= []
Methods
__construct()
public
__construct(ServerSocket $server[, float $keyReceiveTimeout = self::DEFAULT_KEY_RECEIVE_TIMEOUT ][, positive-int $keyLength = self::DEFAULT_KEY_LENGTH ]) : mixed
Parameters
- $server : ServerSocket
- $keyReceiveTimeout : float = self::DEFAULT_KEY_RECEIVE_TIMEOUT
-
Timeout to receive the key on accepted connections.
- $keyLength : positive-int = self::DEFAULT_KEY_LENGTH
-
Length of the random key exchanged on the IPC channel when connecting.
__destruct()
public
__destruct() : mixed
__serialize()
public
final __serialize() : never
Return values
never__unserialize()
public
final __unserialize(array<string|int, mixed> $data) : never
Parameters
- $data : array<string|int, mixed>
Return values
neveraccept()
public
accept(string $key[, Cancellation|null $cancellation = null ]) : ResourceSocket
Parameters
- $key : string
-
A key generated by generateKey().
- $cancellation : Cancellation|null = null
Return values
ResourceSocketclose()
Closes the resource, marking it as unusable.
public
close() : void
Whether pending operations are aborted or not is implementation dependent.
generateKey()
public
generateKey() : non-empty-string
Return values
non-empty-string —Pass the key returned from this method to the connecting context and accept().
getUri()
public
getUri() : non-empty-string
Return values
non-empty-string —URI to use with connect().
isClosed()
Returns whether this resource has been closed.
public
isClosed() : bool
Return values
bool —true if closed, otherwise false.
onClose()
Registers a callback that is invoked when this resource is closed.
public
onClose(Closure $onClose) : void
Parameters
- $onClose : Closure
__clone()
protected
final __clone() : mixed