1.0.4 • Published 3 years ago
lb-websocket v1.0.4
lb-websock
Project setup
npm installCompiles and hot-reloads for development
npm run serveCompiles and minifies for production
npm run buildLints and fixes files
npm run lintCustomize configuration
import
import LbWebsocket from 'lb-websocket';
let websocket = new LbWebsocket({
url: 'ws://xxxxxxx'
});
websocket.onopen = function () {
console.log('connect success');
websocket.send('hello server');
}
websocket.onmessage = function (e) {
console.log(onmessage: ${e.data});
}
websocket.onreconnect = function () {
console.log('reconnecting...');
}
params
- url websocket连接地址
- pingTimeout 未收到消息一段时间后发送ping请求
- pongTimeout 发送ping后消息接收超时时间
- reconnectTimeout 重连超时时间
- pingMsg 心跳检测信息
- repeatLimit 重连限制次数