WebSocketRequestHandler

An HTTP request handler implementation that's used as the entrypoint for clients that want to establish a websocket connection. It will verify the websocket request, and if successful, send back a SWITCHING_PROTOCOLS response, and register a new websocket connection.

Constructors

this
this(WebSocketMessageHandler messageHandler)

Constructs a request handler that will use the given message handler to deal with events from any websocket connections that are established.

Members

Functions

addConnection
void addConnection(WebSocketConnection conn, ServerHttpRequest request)

Adds a connection to the manager and starts listening for messages.

broadcast
void broadcast(ubyte[] data)

Broadcasts a binary message to all connected clients.

broadcast
void broadcast(string text)

Broadcasts a message to all connected clients.

connectionCount
size_t connectionCount()

Gets the number of active connections.

handle
void handle(ServerHttpRequest request, ServerHttpResponse response)

Handles an incoming HTTP request and tries to establish a websocket connection by first verifying the request, then sending a switching- protocols response, and finally registering the new connection with the websocket manager.

removeConnection
void removeConnection(WebSocketConnection conn)

Removes a websocket connection from the manager and closes it. This is called automatically if the client sends a CLOSE frame, but you can also call it yourself.