@lanzs/websocket
v0.0.2
Published
websocket util for browser
Downloads
3
Readme
Websocket
websocket for browser
Install
npm install @lanzs/websocket
Usage
import Websocket from '@lanzs/websocket'
const ws = new Websocket('ws://example.com')
ws.connect(() => {
console.log('ws connected')
})
ws.send('msg')
ws.onMessage((res) => {
console.log('receive message from service')
})
ws.onError((err) => {
console.error('websocket occurred error')
})
ws.close(() => {
console.log('ws closed')
})