1***@qq.com
1***@qq.com
  • 发布:2022-06-10 13:37
  • 更新:2023-01-16 14:43
  • 阅读:430

关于uniapp在APP端websocket发送ArrayBuffer失败

分类:uni-app

在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);  
                });  
2022-06-10 13:37 负责人:无 分享
已邀请:
小枫叶

小枫叶 - 外包接单加v:wlmk1234567 注明来意

6***@qq.com

6***@qq.com - ouyunc

有没有解决

要回复问题请先登录注册