websocketer
v2.1.8
Published
Simple and easy message passing for WebSocket
Downloads
16
Maintainers
Readme
websocketer
Simple and easy message passing for WebSocket
Usage
import { WebSocketer } from 'websocketer'
// server
const server = new WebSocketer(socket)
server.listen('hello', async (data) => {
// data is { nice: 1 }
const result = await heavyFunction(data)
// suppose result is { hello: 'world' }
return result
})
// client
const client = new WebSocketer(socket)
const data = await client.send('hello', { nice: 1 })
// data is { hello: 'world' }