feat:补包修改
This commit is contained in:
parent
aab38515ed
commit
0c32b01285
@ -105,17 +105,17 @@ function handReceiveMessage(client: socket.TCPSocket, sendData, rData: ArrayBuff
|
|||||||
//开始补包
|
//开始补包
|
||||||
if (messageType === 0xF0) {
|
if (messageType === 0xF0) {
|
||||||
//获取消息体长度
|
//获取消息体长度
|
||||||
const messageLength = receiveData[12]
|
const messageLength = receiveData[13]
|
||||||
//分包总数
|
//分包总数
|
||||||
const packages = bytesToDecimal(receiveData.slice(13, 13 + messageLength * 2));
|
const packages = receiveData.slice(14, 14 + messageLength * 2);
|
||||||
const forArr = new Array(packages).fill(1)
|
const forArr = new Array(messageLength).fill(1)
|
||||||
|
|
||||||
forArr.forEach((item, index) => {
|
forArr.forEach((item,index)=>{
|
||||||
const start = index * 2;
|
const start = index * 2;
|
||||||
const end = start + 2;
|
const end = start + 1;
|
||||||
const packageIndex = bytesToDecimal([start, end]);
|
const packageIndex = bytesToDecimal([packages[start],packages[end]]);
|
||||||
console.info(TAG, '补包内容' + JSON.stringify(new Uint8Array(sendData[packageIndex])))
|
console.info(TAG, '补包内容' + JSON.stringify(new Uint8Array(sendData[packageIndex])))
|
||||||
client.send({ data: new Uint8Array(sendData[packageIndex]).buffer });
|
client.send({data:new Uint8Array(sendData[packageIndex]).buffer});
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
const decoder = util.TextDecoder.create('utf-8');
|
const decoder = util.TextDecoder.create('utf-8');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user