feat:修改
This commit is contained in:
parent
526faa97df
commit
5717c83aa7
@ -88,8 +88,9 @@ function handSendMessage(client: socket.TCPSocket, type, data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//处理接收的数据
|
//处理接收的数据
|
||||||
function handReceiveMessage(client: socket.TCPSocket, sendData, receiveData):RES {
|
function handReceiveMessage(client: socket.TCPSocket, sendData, rData:ArrayBuffer):RES {
|
||||||
|
|
||||||
|
const receiveData = new Uint8Array(rData)
|
||||||
//返回的消息类型
|
//返回的消息类型
|
||||||
const messageType = receiveData[1];
|
const messageType = receiveData[1];
|
||||||
//流水号
|
//流水号
|
||||||
@ -100,7 +101,7 @@ function handReceiveMessage(client: socket.TCPSocket, sendData, receiveData):RES
|
|||||||
//获取消息体长度
|
//获取消息体长度
|
||||||
const messageLength = receiveData[12]
|
const messageLength = receiveData[12]
|
||||||
//分包总数
|
//分包总数
|
||||||
const packages = receiveData.slice(13,13 + messageLength*2);
|
const packages = bytesToDecimal(receiveData.slice(13,13 + messageLength*2));
|
||||||
const forArr = new Array(packages).fill(1)
|
const forArr = new Array(packages).fill(1)
|
||||||
|
|
||||||
forArr.forEach((item,index)=>{
|
forArr.forEach((item,index)=>{
|
||||||
@ -113,10 +114,10 @@ function handReceiveMessage(client: socket.TCPSocket, sendData, receiveData):RES
|
|||||||
}else{
|
}else{
|
||||||
const decoder = util.TextDecoder.create('utf-8');
|
const decoder = util.TextDecoder.create('utf-8');
|
||||||
const messageLength = bytesToDecimal([receiveData[9],receiveData[10]]);
|
const messageLength = bytesToDecimal([receiveData[9],receiveData[10]]);
|
||||||
const markLength = receiveData[11].buffer;
|
const markLength = receiveData[11];
|
||||||
const markContent = decoder.decodeWithStream(receiveData.slice(12, 12 + markLength ));
|
const markContent = decoder.decodeWithStream(receiveData.slice(12, 12 + markLength ));
|
||||||
console.info(TAG, 'markContent=>' + markContent)
|
console.info(TAG, 'markContent=>' + markContent)
|
||||||
const tipLength = receiveData[13].buffer;
|
const tipLength = receiveData[13];
|
||||||
const messageContent = decoder.decodeWithStream(receiveData.slice(13 + markLength, 13 + markLength + tipLength));
|
const messageContent = decoder.decodeWithStream(receiveData.slice(13 + markLength, 13 + markLength + tipLength));
|
||||||
console.info(TAG, 'messageContent=>' + messageContent)
|
console.info(TAG, 'messageContent=>' + messageContent)
|
||||||
return {
|
return {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user