WSE (WebSocket Everywhere!) is a lightweight WebSocket wrapper that provides authentication, RPC support, and multi-device messaging.
Goes with client for NodeJS/Browser, and NodeJS server.
Fastify/Express/HTTP-server friendsly - can be easily mixed with regular web-api without dedicated ws port.
Just wanted RPC-like api without brokers and routers.
npm install wseimport { WseServer, WseClient } from 'wse'
// Server
const server = new WseServer({
port: 4200,
identify: ({ accept }) => accept('user-' + Date.now())
})
server.channel.on('chat', (conn, message) => {
server.broadcast('chat', { user: conn.cid, message })
})
server.register('ping', () => 'pong')
// Client
const client = new WseClient({ url: 'ws://localhost:4200' })
await client.connect()
client.send('chat', 'Hello world!')
const result = await client.call('ping')
console.log(result) // 'pong'Yes, it's all here, Docs and API Reference.
Have fun! ❤️
MIT License - Do whatever you like.
Russian warship - go fuck yourself! 🖕