@axiljs/websocket
v0.3.1
Published
AxilJS RFC 6455 WebSocket server with rooms and broadcasting
Maintainers
Readme
@axiljs/websocket
RFC 6455 WebSocket server with rooms, broadcasting, and ping/pong.
Part of the AxilJS ecosystem.
Install
npm install @axiljs/websocketUsage
import { WSServer } from '@axiljs/websocket'
const wss = new WSServer(app.getServer(), { path: '/ws' })
wss.on('connection', (client) => {
wss.join(client, 'general')
client.sendJSON({ type: 'welcome', id: client.id })
client.on('message', (data) => {
wss.toRoomJSON('general', { from: client.id, data: data.toString() })
})
})Full docs: github.com/SyntaxilitY/AxilJS
