在H5端调试完全没问题,但是在app端就有问题,使用了plus-websocket,也不行
socket.connectSocket({
url: 'wss://cloud.alientek.com/connection/'+this.token+'/org/638?token='+this.randomstr()
});
socket.onSocketOpen((res)=>{
this.socketopen = true;
console.log('WebSocket连接已打开!');
let byteArray2 = [0x38, 0x31, 0x35, 0x31, 0x31, 0x36, 0x39, 0x39, 0x30, 0x32, 0x35, 0x35, 0x36, 0x32, 0x39, 0x30, 0x31, 0x31, 0x35, 0x32];
let buffer = new ArrayBuffer(21);
let dataView = new DataView(buffer);
let num = 1;
dataView.setInt8(0, 1)
for(let i=0;i<byteArray2.length;i++){
dataView.setInt8(num+i, byteArray2[i]);
}
console.log(dataView, dataView.getInt8(0));
socket.sendSocketMessage({
data:dataView
})
});
socket.onSocketMessage((res)=> {
//console.log(res);
var uint8_msg = new Uint8Array(res.data);
var decodedString = String.fromCharCode.apply(null, uint8_msg);
console.log(decodedString);
// parse,转成json数据
// var data = JSON.parse(decodedString);
// console.log(data);
});
2 个回复
小枫叶 - 外包接单加v:wlmk1234567 注明来意
https://blog.csdn.net/baidu_38424904/article/details/120543878
参考下
6***@qq.com - ouyunc
有没有解决