class Server

Properties

protected RateLimiter|null $rateLimiter

Cached rate limiter instance.

Methods

__construct(ChannelManager $channels, EventHandler $handler)

Create a new server instance.

void
open(Connection $connection)

Handle a client connection.

void
message(Connection $from, string $message)

Handle a new message received by the connected client.

void
control(Connection $from, int $opcode)

Handle a low-level WebSocket control frame.

void
close(Connection $connection)

Handle a client disconnection.

void
error(Connection $connection, Throwable $exception)

Handle an error.

void
ensureWithinConnectionLimit(Connection $connection)

Ensure the server is within the connection limit.

void
ensureWithinRateLimit(Connection $connection)

Ensure the connection is within the message rate limit.

void
verifyOrigin(Connection $connection)

Verify the origin of the connection.

Details

at line 33
__construct(ChannelManager $channels, EventHandler $handler)

Create a new server instance.

Parameters

ChannelManager $channels
EventHandler $handler

at line 42
void open(Connection $connection)

Handle a client connection.

Parameters

Connection $connection

Return Value

void

at line 70
void message(Connection $from, string $message)

Handle a new message received by the connected client.

Parameters

Connection $from
string $message

Return Value

void

at line 117
void control(Connection $from, int $opcode)

Handle a low-level WebSocket control frame.

Parameters

Connection $from
int $opcode

Return Value

void

at line 135
void close(Connection $connection)

Handle a client disconnection.

Called from WebSocketHandler::onClose() when the client has already disconnected. Only cleans up Reverb state — does NOT try to close the connection again (the fd is already gone).

Parameters

Connection $connection

Return Value

void

at line 158
void error(Connection $connection, Throwable $exception)

Handle an error.

Parameters

Connection $connection
Throwable $exception

Return Value

void

at line 186
protected void ensureWithinConnectionLimit(Connection $connection)

Ensure the server is within the connection limit.

Uses SharedState for global connection counting across workers.

Parameters

Connection $connection

Return Value

void

at line 207
protected void ensureWithinRateLimit(Connection $connection)

Ensure the connection is within the message rate limit.

Parameters

Connection $connection

Return Value

void

at line 233
protected void verifyOrigin(Connection $connection)

Verify the origin of the connection.

Parameters

Connection $connection

Return Value

void