- basic
- echo
- fast-ws
HTTP Connection
Remote IP address
Accept protocol upgrade
Listen on builtin event. Builtin events:
open
,disconnect
,drained
,message
,binary
Remove listener
Remove all listener
Join channel
Quit channel
Send message to client
Send binary to client
Send message to channel
Send binary to channel
Close connection
Extends basic. But support event, reply and object serialize.
Listen on builtin event or custom event.
ws.on('hello', ({ data, reply }: WSEvent) => {
reply(`Hello ${data}`)
})
ws.on('message', (message) => {
ws.sendMessage(message)
})
Emit event to client
Emit event to channel
Message data type (
event
ormessage
)
Data send from client
Event name
Reply data. If client don't want reply, this function will not work. And only custom event can reply. Node: Reply ID could timeout, you can set longer reply timeout at client.