globalData: {
localSocket: {},
callback: function () {},
exceptionClose: true
},
// 初始化socket
initSocket() {
let that = this;
that.globalData.exceptionClose=true;
var cookie = '';
var index = 0;
for (var key in that.getCookieSync('cookieKey')) {
if (index > 0) {
cookie += ';'
}
cookie += key + '=' + that.getCookieSync('cookieKey')[key]
index = index + 1;
}
that.globalData.localSocket = wx.connectSocket({
url: api.WebSocketUrl,
header:{'Cookie': cookie}
})
that.globalData.localSocket.onOpen(function (res) {
console.log('WebS
微信小程序实现即时通讯聊天功能实现websocket长连接
最新推荐文章于 2022-06-13 20:45:47 发布