Skip to main content

Quik Framework :: WebSocket Express

Provides a ws adapter that attaches WebSocket upgrade handling to the active @quik/http-express HTTP server.

Installation

npm install @quik/websocket-express

Usage

Load @quik/websocket, @quik/http-express, and @quik/websocket-express in your bootstrap modules and enable the WebSocket server flag:

await setup({
flags: {
startHttpServer: true,
startWebSocketServer: true
},
modules: [
WebSocketModule,
HttpExpressModule,
WebSocketExpressModule
]
});

The adapter listens on websocket.path and uses QWebSocketHeartbeatService for browser-compatible ping/pong checks.

API Highlights

  • QExpressWebSocketEngine binds a ws server to the current HTTP engine and implements IQWebSocketEngine.
  • engine.send(connectionId, data) writes to one connection; get the active engine with getWebSocketEngine() from @quik/websocket.
  • engine.broadcast(data) writes to every open connection.

API Reference

Generated API documentation is available in the websocket-express API section.