WebSocketManager

An event-loop based websocket manager thread that handles incoming messages and passes them off to their connection's message handler. This manager is enabled by setting the configuration option enableWebSockets to true.

This manager controls the list of connected websocket clients, so in practice, you will most often use the manager for its broadcast methods to send out messages to all clients. You can get an instance of this manager from a request context like so: ctx.server.getWebSocketManager()

Constructors

this
this()

Constructs a new manager with an initially empty socket set.

Members

Functions

broadcast
void broadcast(ubyte[] bytes)

Broadcasts a binary message to all connected clients.

broadcast
void broadcast(string text)

Broadcasts a text message to all connected clients.

deregisterConnection
void deregisterConnection(WebSocketConnection conn)

Removes an existing websocket connection from this manager and closes the socket.

registerConnection
void registerConnection(Socket socket, WebSocketMessageHandler handler)

Registers a new websocket connection to this manager, and begins listening for messages to pass on to the given handler.

stop
void stop()

Stops the manager thread.