problem description
websocket, this.socketApi.controlsendSock(controlData)
js
websocket2
the environmental background of the problems and what methods you have tried
related codes
/ / Please paste the code text below (do not replace the code with pictures)
websocket.js
function websocket(){
var url = "wss://"+getPostUrl()+":9567/deviceop";
ws =new WebSocket(url);
ws.binaryType = "arraybuffer";
ws.onmessage = function(event){
console.log("data === " + event.data);
if(event.data instanceof ArrayBuffer){
var buffer = event.data;
var data = parse(buffer)
var newdata = JSON.parse(data)
}
}
ws.onopen = function (event) {
console.log("")
}
ws.onclose = function(event){
console.log("")
}
ws.onerror = function () {
// wsData="qweqweuqeg iqwge iqgwiug"
console.log("WebSocket");
}
}
function controlsendSock(controlData){
ws.send(controlData)
}
websocket();
export{ws,controlsendSock}
what result do you expect? What is the error message actually seen?
newdata