Router API Reference
The router maps WebSocket events and HTTP routes declared with attributes on controllers.
Class: Sockeon\Sockeon\Core\Router
Method Summary
php
public function setServer(Server $server): void
public function register(SocketController $controller): void
public function dispatch(string $clientId, string $event, array $data): void
public function dispatchSpecialEvent(string $clientId, string $eventType): void
public function dispatchHttp(Request $request): mixed
public function getHttpRoutes(): array
public function getWebSocketRoutes(): arrayTypical Usage
You normally do not instantiate or call the router directly. Server handles this when you register controllers.
php
$server = new Server($config);
$server->registerController(new ChatController());
$server->registerController(new ApiController());
$server->run();Route Registration Behavior
When register() runs, Sockeon scans controller methods and maps:
#[SocketOn('event.name')]to WebSocket event routes#[OnConnect]and#[OnDisconnect]to special lifecycle handlers#[HttpRoute('METHOD', '/path')]to HTTP routes (with path parameters)
Introspection Helpers
getWebSocketRoutes() and getHttpRoutes() return internal route arrays used by the framework runtime.
These are useful for debugging tooling but are not intended as stable schema contracts.