From 3b78707f0d8b75ee7d7ee6c74f86f0fcbf08cd6b Mon Sep 17 00:00:00 2001 From: azw Date: Tue, 15 Aug 2023 21:16:22 +0800 Subject: [PATCH] 1 --- tools/robot/clientnet.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/robot/clientnet.js b/tools/robot/clientnet.js index 87ab7426..4bd5b299 100644 --- a/tools/robot/clientnet.js +++ b/tools/robot/clientnet.js @@ -56,20 +56,20 @@ class ClientNet { async connect() { this.conn = await ws.connect(this.url); - this.on('binary', this.#onReceive.bind(this)); + this.on('binary', this.onReceive.bind(this)); } on(eventName, ...args) { this.conn.on(eventName, ...args); } - async #onReceive(inStream) { + async onReceive(inStream) { inStream.on('readable', async () => { //console.log('inStream.readable'); const newData = inStream.read(); if (newData) { this.recvBuf = Buffer.concat([this.recvBuf, newData]); - await this.#onParsePacket(); + await this.onParsePacket(); } }); inStream.on('end', () => { @@ -80,7 +80,7 @@ class ClientNet { }); } - async #onParsePacket() { + async onParsePacket() { let offset = 0; while (this.recvBuf.length > offset + 12) { const msgSize = this.recvBuf.readUInt16LE(offset + 0); @@ -88,7 +88,7 @@ class ClientNet { const seqId = this.recvBuf.readUInt32LE(offset + 4); const magicCode = this.recvBuf.readUInt16LE(offset + 8); if (this.recvBuf.length >= offset + 12 + msgSize) { - await this.#processMsg(msgId, + await this.processMsg(msgId, this.recvBuf.slice ( offset + 12, @@ -102,7 +102,7 @@ class ClientNet { this.recvBuf = this.recvBuf.slice(offset); } - async #processMsg(msgId, buff) { + async processMsg(msgId, buff) { const handlers = this.msgHandlerMap.get(msgId); if (handlers) { let msg = null;