1.0.4 • Published 2 years ago
lb-websocket v1.0.4
lb-websock
Project setup
npm install
Compiles and hot-reloads for development
npm run serve
Compiles and minifies for production
npm run build
Lints and fixes files
npm run lint
Customize 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 重连限制次数