From 6114dba7aaccfd2d4491f59f9ebb108d3c93708a Mon Sep 17 00:00:00 2001 From: SmallMain Date: Mon, 28 Oct 2024 17:22:22 +0800 Subject: [PATCH] =?UTF-8?q?[adapters]=20=E4=BF=AE=E5=A4=8D=20Worker=20?= =?UTF-8?q?=E4=B8=BB=E5=8A=A8=E5=90=91=E4=B8=BB=E7=BA=BF=E7=A8=8B=E9=80=9A?= =?UTF-8?q?=E4=BF=A1=E6=97=A0=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adapters/platforms/wechat/res/workers/ipc-worker.js | 8 ++++---- adapters/platforms/wechat/worker/ipc-main.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/adapters/platforms/wechat/res/workers/ipc-worker.js b/adapters/platforms/wechat/res/workers/ipc-worker.js index 902c1570..cdb019b8 100644 --- a/adapters/platforms/wechat/res/workers/ipc-worker.js +++ b/adapters/platforms/wechat/res/workers/ipc-worker.js @@ -41,7 +41,7 @@ var handlers = {}; function callToMain(cmd, args) { const id = ++_cmdId; - args.unshift(id, cmd); + const msg = [id, cmd, args]; if (typeof args[args.length - 1] === "function") { const callback = args.pop(); @@ -49,13 +49,13 @@ function callToMain(cmd, args) { } if (CC_WORKER_DEBUG) { - console.log("worker send call:", args); + console.log("worker send call:", msg); } if (CC_WORKER_SCHEDULER) { - sendScheduler.send(args); + sendScheduler.send(msg); } else { - worker.postMessage(args); + worker.postMessage(msg); } } diff --git a/adapters/platforms/wechat/worker/ipc-main.js b/adapters/platforms/wechat/worker/ipc-main.js index ca3172b6..7d7558a5 100644 --- a/adapters/platforms/wechat/worker/ipc-main.js +++ b/adapters/platforms/wechat/worker/ipc-main.js @@ -169,7 +169,7 @@ const ipcMain = { const desc = descs[key]; if (typeof desc.value === "function") { - const cmd = ++this._cmd; + const cmd = --this._cmd; this.handlers[cmd] = { name, key, @@ -178,7 +178,7 @@ const ipcMain = { }; } else { // getter/setter - const cmd1 = ++this._cmd; + const cmd1 = --this._cmd; this.handlers[cmd1] = { name, key: "get_" + key, @@ -187,7 +187,7 @@ const ipcMain = { }, callback: null, }; - const cmd2 = ++this._cmd; + const cmd2 = --this._cmd; this.handlers[cmd2] = { name, key: "set_" + key, @@ -195,7 +195,7 @@ const ipcMain = { obj[key] = args[0]; } }; - const cmd3 = ++this._cmd; + const cmd3 = --this._cmd; this.handlers[cmd3] = { name, key: "write_" + key,