fix: 暂存
This commit is contained in:
		
						commit
						b612c376ee
					
				| @ -12,12 +12,14 @@ interface RES { | |||||||
|   message?: string |   message?: string | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| const config = { | const config = { | ||||||
|   address: '172.37.55.191', |   address: '172.37.55.191', | ||||||
|   port: 40000 |   port: 40000 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export default async function tcp2ByteRequest(data): Promise<RES> { | export default async function tcp2ByteRequest(data): Promise<RES> { | ||||||
|  | 
 | ||||||
|   return new Promise(async (resolve, reject) => { |   return new Promise(async (resolve, reject) => { | ||||||
|     const tcpClient: socket.TCPSocket = socket.constructTCPSocketInstance() |     const tcpClient: socket.TCPSocket = socket.constructTCPSocketInstance() | ||||||
| 
 | 
 | ||||||
| @ -77,7 +79,6 @@ function handSendMessage(client: socket.TCPSocket, type, data) { | |||||||
|     case '02-21-000012': |     case '02-21-000012': | ||||||
|     case '02-21-000014': |     case '02-21-000014': | ||||||
|       data.forEach((item) => { |       data.forEach((item) => { | ||||||
|         console.log(TAG, JSON.stringify(item)) |  | ||||||
|         client.send({ data: new Uint8Array(item).buffer }) |         client.send({ data: new Uint8Array(item).buffer }) | ||||||
|       }) |       }) | ||||||
|       break; |       break; | ||||||
| @ -98,6 +99,8 @@ function handReceiveMessage(client: socket.TCPSocket, sendData, rData: ArrayBuff | |||||||
|   console.info(TAG, 'receiveData=>' + JSON.stringify(receiveData)) |   console.info(TAG, 'receiveData=>' + JSON.stringify(receiveData)) | ||||||
|   //返回的消息类型
 |   //返回的消息类型
 | ||||||
|   const messageType = receiveData[1]; |   const messageType = receiveData[1]; | ||||||
|  |   console.info(TAG, 'receiveData messageType=>' + JSON.stringify(receiveData)) | ||||||
|  | 
 | ||||||
|   //流水号
 |   //流水号
 | ||||||
|   const lsh = bytesToDecimal([receiveData[2], receiveData[3]]); |   const lsh = bytesToDecimal([receiveData[2], receiveData[3]]); | ||||||
| 
 | 
 | ||||||
| @ -109,22 +112,22 @@ function handReceiveMessage(client: socket.TCPSocket, sendData, rData: ArrayBuff | |||||||
|     const packages = receiveData.slice(14, 14 + messageLength * 2); |     const packages = receiveData.slice(14, 14 + messageLength * 2); | ||||||
|     const forArr = new Array(messageLength).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 + 1; |       const end = start + 1; | ||||||
|       const packageIndex =  bytesToDecimal([packages[start],packages[end]]); |       const packageIndex = bytesToDecimal([packages[start], packages[end]]); | ||||||
|       console.info(TAG, '补包内容' + JSON.stringify(new Uint8Array(sendData[packageIndex-1]))) |       console.info(TAG, '补包内容' + JSON.stringify(new Uint8Array(sendData[packageIndex -1]))) | ||||||
|       client.send({data:new Uint8Array(sendData[packageIndex-1]).buffer}); |       client.send({ data: new Uint8Array(sendData[packageIndex -1]).buffer }); | ||||||
|     }) |     }) | ||||||
|   } 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]; |     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 + messageType, 'markContent=>' + markContent) | ||||||
|     const tipLength = receiveData[13]; |     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 + messageType, 'messageContent=>' + messageContent) | ||||||
|     return { |     return { | ||||||
|       code: markContent, |       code: markContent, | ||||||
|       message: messageContent |       message: messageContent | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user