class WebSocketKernel extends Server

Properties

protected HandshakeHandler $handshakeHandler from  Server
protected Dispatcher|null $event from  Server
protected StdoutLoggerInterface $logger from  Server
protected string $serverName from  Server

Methods

__construct(Container $container)

No description

from  Server
void
bootstrapForServer(string $serverName)

Bootstrap the application and initialize WebSocket components.

from  Server
void
onHandshake(Request $request, Response $response)

Handle the WebSocket handshake request.

from  Server
void
onMessage(Server $server, Frame $frame)

Handle a WebSocket message.

from  Server
void
onClose(Server $server, int $fd, int $reactorId)

Handle a WebSocket connection close.

from  Server
Response
handleException(Throwable $throwable)

Handle an exception using the application's exception handler.

Server
getServer()

Get the Swoole server instance.

from  Server
getSender()

Get the WebSocket sender instance.

from  Server
getRouter()

Get the router instance for WebSocket handshake route matching.

from  Server
string
getServerName()

Get the server name.

from  Server
setServerName(string $serverName)

Set the server name.

from  Server
int
getFd(Response $response)

Get the file descriptor from the response.

from  Server
void
deferOnOpen(Request $request, object $instance, Server $server, int $fd)

Defer the onOpen callback after handshake completes.

from  Server
void
reportCallbackFailure(Throwable $throwable)

Report a WebSocket callback failure without escaping the native boundary.

from  Server

Details

in Server at line 54
__construct(Container $container)

No description

Parameters

Container $container

in Server at line 73
void bootstrapForServer(string $serverName)

Bootstrap the application and initialize WebSocket components.

Called by the server boot process (Server\Server::registerSwooleEvents) before $server->start(). Resolves the HTTP Kernel to ensure the application is bootstrapped (routes compiled, middleware synced) even in WS-only setups where HttpServer\Server may not be present. The hasBeenBootstrapped() guard makes this idempotent.

Parameters

string $serverName

Return Value

void

in Server at line 95
void onHandshake(Request $request, Response $response)

Handle the WebSocket handshake request.

Converts the Swoole request to HttpFoundation, validates the WebSocket security key, dispatches through the Router for route matching and middleware execution, then builds the 101 Switching Protocols response.

Parameters

Request $request
Response $response

Return Value

void

in Server at line 178
void onMessage(Server $server, Frame $frame)

Handle a WebSocket message.

Parameters

Server $server
Frame $frame

Return Value

void

in Server at line 236
void onClose(Server $server, int $fd, int $reactorId)

Handle a WebSocket connection close.

Parameters

Server $server
int $fd
int $reactorId

Return Value

void

at line 21
protected Response handleException(Throwable $throwable)

Handle an exception using the application's exception handler.

Overrides the base WebSocket handler to use the app-level exception handler, matching how the HTTP kernel delegates exception handling.

Parameters

Throwable $throwable

Return Value

Response

in Server at line 304
Server getServer()

Get the Swoole server instance.

Return Value

Server

in Server at line 313
Sender getSender()

Get the WebSocket sender instance.

Return Value

Sender

in Server at line 324
protected Router getRouter()

Get the router instance for WebSocket handshake route matching.

Override in subclasses to use an isolated router for packages that register their own server entry (e.g. Reverb).

Return Value

Router

in Server at line 332
string getServerName()

Get the server name.

Return Value

string

in Server at line 346
Server setServerName(string $serverName)

Set the server name.

Boot-only. Mutates the worker-lifetime WebSocket handler before Swoole starts; runtime use races across connections and changes emitted server context.

Parameters

string $serverName

Return Value

Server

in Server at line 356
protected int getFd(Response $response)

Get the file descriptor from the response.

Parameters

Response $response

Return Value

int

in Server at line 364
protected void deferOnOpen(Request $request, object $instance, Server $server, int $fd)

Defer the onOpen callback after handshake completes.

Parameters

Request $request
object $instance
Server $server
int $fd

Return Value

void

in Server at line 392
protected void reportCallbackFailure(Throwable $throwable)

Report a WebSocket callback failure without escaping the native boundary.

Parameters

Throwable $throwable

Return Value

void