feat:修改

This commit is contained in:
surenjun 2025-03-05 09:03:00 +08:00
parent 0cb15e4c04
commit 7a197098aa
2 changed files with 10 additions and 8 deletions

View File

@ -73,13 +73,14 @@ function handSendMessage(client: socket.TCPSocket, type, data) {
case '02-21-000012':
case '02-21-000014':
data.forEach((item) => {
client.send({ data: new Uint8Array(item) })
console.log(TAG, JSON.stringify(item))
client.send({ data: new Uint8Array(item).buffer })
})
break;
case '02-21-000010':
case '02-21-000011':
case '02-21-000013':
client.send({ data: new Uint8Array(data) })
client.send({ data: new Uint8Array(data).buffer })
break;
default:break;
@ -107,7 +108,7 @@ function handReceiveMessage(client: socket.TCPSocket, sendData, receiveData):RES
const end = start + 2;
const packageIndex = bytesToDecimal([start,end]);
console.info(TAG, '补包内容' + JSON.stringify(new Uint8Array(sendData[packageIndex])))
client.send({data:new Uint8Array(sendData[packageIndex])});
client.send({data:new Uint8Array(sendData[packageIndex]).buffer});
})
}else{
const decoder = util.TextDecoder.create('utf-8');

View File

@ -447,14 +447,15 @@ export default class TcpToByte {
// 图片处理
getBytePhoto(base64) {
const thisBase64 = base64.split(',')[1]
const buffer = Buffer.from(thisBase64, 'base64');
//@ts-ignore
const arr = Array.from(buffer)
const buffer = Buffer.from(base64, 'base64');
let arr = []
for (let i = 0; i < buffer.length; i++) {
arr.push(buffer[i]);
}
return (string2Bytes(arr.length + 5, 4 * 8)).concat([0]).concat(string2Bytes(arr.length, 4 * 8)).concat(arr)
}
//随机获取流水号
getRandomLsh() {
return Math.floor(Math.random() * 65535);