@otools/websocket
v0.4.0
Published
websocket util for browser
Downloads
4
Readme
Websocket
websocket for browser
Install
npm install @otools/websocket
Usage
import Websocket from '@otools/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')
})