socket地址配置
// 根目录/config/index.js
const LIVESOCKET = "wss://配置您的wss地址"
socket说明
/**
根目录/utils/websocket.js
该websocket类基于uni的websocket,支持websocket链接、断开、断线重连、心跳检测和发送消息
**/
// 链接websocket
import wsRequest from '@/utils/websocket.js'
let websocket = new wsRequest(6000)
Vue.prototype.$socket = websocket // 将socket实例绑定至全局vue原型链上
// 断线重连
this.$socket.manualReconnect()
// 关闭链接
this.$socket.colse()
// 发送消息
this.$socket.send(JSON.stringify({
type: 'readmsg',
data: {
}
}))