Server
class Server implements BootstrapsForServer, OnHandshakeInterface, OnCloseInterface, OnMessageInterface
Properties
| protected HandshakeHandler | $handshakeHandler | ||
| protected Dispatcher|null | $event | ||
| protected StdoutLoggerInterface | $logger | ||
| protected string | $serverName |
Methods
Bootstrap the application and initialize WebSocket components.
Handle the WebSocket handshake request.
Handle a WebSocket message.
Handle a WebSocket connection close.
Get the Swoole server instance.
Get the server name.
Set the server name.
Get the file descriptor from the response.
Defer the onOpen callback after handshake completes.
Report a WebSocket callback failure without escaping the native boundary.
Details
at line 54
__construct(Container $container)
No description
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.
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.
at line 178
void
onMessage(Server $server, Frame $frame)
Handle a WebSocket message.
at line 236
void
onClose(Server $server, int $fd, int $reactorId)
Handle a WebSocket connection close.
at line 294
protected Response
handleException(Throwable $throwable)
Handle an exception that occurred during the handshake.
Subclasses (e.g. Foundation\Http\WebSocketKernel) override this to use the application's exception handler instead of the default.
at line 304
Server
getServer()
Get the Swoole server instance.
at line 313
Sender
getSender()
Get the WebSocket sender instance.
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).
at line 332
string
getServerName()
Get the server name.
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.
at line 356
protected int
getFd(Response $response)
Get the file descriptor from the response.
at line 364
protected void
deferOnOpen(Request $request, object $instance, Server $server, int $fd)
Defer the onOpen callback after handshake completes.
at line 392
protected void
reportCallbackFailure(Throwable $throwable)
Report a WebSocket callback failure without escaping the native boundary.