class Server

Methods

__construct(ChannelManager $channels, EventHandler $handler, Limiter $messageRateLimiter)

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.

messageLimit(Connection $connection)

Build the message limit for a connection.

void
verifyOrigin(Connection $connection)

Verify the origin of the connection.

Details

at line 32
__construct(ChannelManager $channels, EventHandler $handler, Limiter $messageRateLimiter)

Create a new server instance.

Parameters

ChannelManager $channels
EventHandler $handler
Limiter $messageRateLimiter

at line 42
void open(Connection $connection)

Handle a client connection.

Parameters

Connection $connection

Return Value

void

at line 90
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 166
void control(Connection $from, int $opcode)

Handle a low-level WebSocket control frame.

Parameters

Connection $from
int $opcode

Return Value

void

at line 184
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 237
void error(Connection $connection, Throwable $exception)

Handle an error.

Parameters

Connection $connection
Throwable $exception

Return Value

void

at line 261
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 282
protected void ensureWithinRateLimit(Connection $connection)

Ensure the connection is within the message rate limit.

Parameters

Connection $connection

Return Value

void

at line 298
protected Limit messageLimit(Connection $connection)

Build the message limit for a connection.

Parameters

Connection $connection

Return Value

Limit

at line 309
protected void verifyOrigin(Connection $connection)

Verify the origin of the connection.

Parameters

Connection $connection

Return Value

void