DocsReal-TimeWebSocketsReal-TimeWebSocketsRFC 6455 WebSocket server with rooms.1 min readDocumentationEdit this pageSetup# typescriptimport { WSServer } from '@axiljs/websocket' const wss = new WSServer(app.getServer(), { path: '/ws' }) wss.on('connection', (client) => { client.sendJSON({ type: 'welcome', id: client.id }) wss.join(client, 'chat') client.on('message', (data) => { wss.toRoomJSON('chat', { from: client.id, text: data.toString() }) }) }) Client API# typescriptclient.send('text') client.sendJSON({ type: 'data' }) client.sendBinary(buffer) client.close(1000, 'reason') client.isOpen Broadcasting# typescriptwss.broadcastJSON(data) wss.broadcastJSON(data, [excludeId]) wss.toRoomJSON('room', data)PreviousEvent BusNextQueue