WeChat Mini Programs's wx.sendSocketMessage interface can not send ArrayBuffer or is it wrong?

currently, a project is under development. The following code is used to send data on Wechat developer"s tool. The server can receive the data and parse it successfully, but the debug QR code of scanning developer"s tool cannot send data on the real phone, and an error is reported in the fail interface

.

Code:

wx.sendSocketMessage({
    data: new Uint8Array([1,0,2,0,1]),
    success:function(e){
         console.log(e)
    },
    fail:function(e){
         console.log(e)
    },
    complete:function(e){
         console.log(e)
    }
});

error message:

sendSocketMessage:fail invaild data type

official documents:

clipboard.png
trouble thinking no to come to help, is the code wrong or other reasons.


first of all, I would like to thank the people who have been invited for their attention. In addition, a solution to this problem has been found through information query on the Internet. The reason for this problem is the lack of understanding of binary data operation. The solution is provided below.

// sendSocketMessageArrayBuffernew Uint8ArrayArrayBufferarrayBuffer
var init8arr = new Uint8Array([1,0,2,0,1]);
wx.sendSocketMessage({
    data: init8arr.buffer,
    success:function(e){
         console.log(e)
    },
    fail:function(e){
         console.log(e)
    },
    complete:function(e){
         console.log(e)
    }
});

another problem is that the real machine Mini Program does not support new TextDecoder () objects, functions, and solutions:

function decodeUTF8(arr) {
    var str = '';
    for (var i = 0; i < arr.length; iPP) {
        str += String.fromCharCode(arr[i]);
    }
    return decodeURIComponent(escape(str));
}
 
console.log(decodeUTF8([230, 177, 137, 229, 173, 151]));

the above two problems are the inconsistencies between Wechat developer's tools and the real machine environment.

reference article:

Uint8Array copy (buffer)
ie,TextDecoder.decode () function is not available, fromCharCode output Chinese garbled

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9bf9e-189e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9bf9e-189e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?