1.0.6 • Published 5 years ago

ws-remind v1.0.6

Weekly downloads
14
License
ISC
Repository
-
Last release
5 years ago

websocket 消息推送插件

使用

npm i -S ws-remind  

入参 1. string

import WSremind from 'ws-remind'  
let wsRemind = new WSremind(WSurl)
直接传入ws路径
  1. object
import WSremind from 'ws-remind'  
let option = {
  url: '...', // ws路径
  count: 0', // 断开重连最大次数设置,10秒重连一次。
  // remind 设置接收到消息,提醒方式,不设置默认alert弹出接收到的信息
  remind: res => { 
    console.log('remind', res)
  }, 
}
let wsRemind = new WSremind(option)

方法

方法名作用参数返回值版本
connect链接wsnullnull1.0.3
send向服务器推送消息stringnull1.0.3
close断开链接nullnull1.0.3
getState获取当前连接状态null0-connect,1-open(连接中),2-closeing,3-closed(断开);1.0.3
setUrl设置ws路径Stringnull1.0.3
setRemind设置消息提示的方法Functionnull1.0.3
setCount设置重连次数Numbernull1.0.3
1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago