Router

Purpose of this Component

The Router component is composed using parts of the Symfony Routing Component. It allows multiple WebSocket apps to be run on the same server distinguished by HTTP endpoints.

Note: This component is bundled within the App class and includes a UrlMatcher to make your life easy.

Events triggered by this Component

As found in the API Docs: Triggered events are propagated through a HttpServerInterface object passed to the __construct.

  • onOpen (ConnectionInterface $conn, RequestInterface $request = null) - A new client connection has been opened
  • onClose (ConnectionInterface $conn) - A client connection is about to, or has closed
  • onMessage (ConnectionInterface $from, string $message) - A data message has been received
  • onError (ConnectionInterface $from, Exception $error) - An error has occurred with a Connection

Configuration properties

  • $allowedOrigins - An array of strings of origins (URLs) to allow.

Functions callable on Connections

  • send (string $message) - Send a message (string) to the client
  • close - Gracefully close the connection to the client

Wraps other components nicely

Wrapped by other components nicely

Usage

It is recommended using the Router through the App class where all the assembly is already done for you.

If you want to compose everything yourself please see the Symfony Routing Documentation.