小程序sendDanmu方法频繁调用问题
在websocket中频繁调用sendDanmu时,数据没有问题,但是会重复显示第一条数据
wx.connectSocket({ url: `wss://${domainName}.com/ws/live/ranks?cid=${options.cid}`, success: function(res) { wx.showToast({ title: '连接服务器成功', }) wx.onSocketMessage(function(res) { var resData = JSON.parse(res.data); if (resData.event == 'LIVE_MESSAGE') { var dataSource = resData.data.message; console.log(dataSource) that.setData({ testData: dataSource }) that.videoContext.sendDanmu({ text: dataSource.value, color: dataSource.color }) } }) }, fail: function(res) { wx.showToast({ title: '连接服务器失败', }) } }) |
