UDPSocket.onMessage IOS系统收不到硬件返回的消息,是什么原因?
udpSocket.bind(8888) UDPSocket.onMessage IOS系统通过指定的硬件设备ip加端口能发送出去消息,硬件设备也能收到消息,但收不到硬件设备返回的消息,Andriod系统和硬件设备可以相互通讯,是什么原因 sendMessage(){
if (this.mydata.isSend){
return ;
}
const udpSocket = wx.createUDPSocket()
this.mydata.isSend = true
const that = this;
let ip = this.mydata.remoteUrl.ip
let port = this.mydata.remoteUrl.port
let message = this.mydata.message
if(message.trim() === ''){
wx.showToast({
title: '请输入内容',
})
return ;
}
udpSocket.bind()
udpSocket.send({
address: '192.168.4.1',
port:'1000',
message: message,
})
this.mydata.isSend = false
let list = this.data.messageList
let obj = {
text: message,
from : 2
}
list.push(obj)
this.setData({
messageList : list
})
},
onLoad: function (options) {
var that = this;
this.initUdpSocket()
that.getConnectedWifi();
},
initUdpSocket(){
const udpSocket = wx.createUDPSocket();
if(udpSocket === null){
console.log('暂不支持')
return ;
}
udpSocket.bind(8888)
udpSocket.onListening(function(res){
console.log('监听中...')
console.log(res)
})
udpSocket.onMessage(function (res) {
console.log('ddddd',res)
})
},