From ae04399755fe2905e0e19b68dbafd402ccef6c58 Mon Sep 17 00:00:00 2001 From: youxia <675567585@qq.com> Date: Sat, 14 Sep 2024 00:14:53 +0800 Subject: [PATCH] fix: id --- packages/client/package.json | 2 +- packages/client/src/FeiyunClient.ts | 11 ++++++----- packages/feiyun/package.json | 2 +- packages/handler/package.json | 2 +- packages/server/package.json | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/client/package.json b/packages/client/package.json index e6238e4..cf6bfaf 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,7 +1,7 @@ { "name": "@feiyun/client", "repository": "https://github.com/hxg2050/feiyun.git", - "version": "0.0.9", + "version": "0.0.10", "private": false, "type": "module", "main": "./src/index.ts", diff --git a/packages/client/src/FeiyunClient.ts b/packages/client/src/FeiyunClient.ts index 640c683..77ed1f3 100644 --- a/packages/client/src/FeiyunClient.ts +++ b/packages/client/src/FeiyunClient.ts @@ -120,12 +120,12 @@ export class FeiyunClient { * Send message to server. */ send(name: string, data?: any) { - ++this.index; + const index = ++this.index; if (this.online) { - this.ws.send(JSON.stringify([this.index, name, data])); + this.ws.send(JSON.stringify([index, name, data])); } else { this.queue.push(() => { - this.ws.send(JSON.stringify([this.index, name, data])); + this.ws.send(JSON.stringify([index, name, data])); }); } } @@ -167,9 +167,10 @@ export class FeiyunClient { * @returns */ async request(name: string, data?: any) { - this.send(name, data) + this.send(name, data); + const index = this.index; return new Promise((resolve, reject) => { - this.requestCallback[this.index] = (msg: any) => { + this.requestCallback[index] = (msg: any) => { resolve(msg) } }) diff --git a/packages/feiyun/package.json b/packages/feiyun/package.json index 8e7561c..56126e3 100644 --- a/packages/feiyun/package.json +++ b/packages/feiyun/package.json @@ -1,7 +1,7 @@ { "name": "feiyun", "repository": "https://github.com/hxg2050/feiyun.git", - "version": "0.3.0", + "version": "0.3.1", "private": false, "type": "module", "main": "./src/index.ts", diff --git a/packages/handler/package.json b/packages/handler/package.json index e80a224..fb59021 100644 --- a/packages/handler/package.json +++ b/packages/handler/package.json @@ -1,6 +1,6 @@ { "name": "@feiyun/handler", - "version": "0.1.0", + "version": "0.1.1", "license": "MIT", "type": "module", "main": "./src/index.ts", diff --git a/packages/server/package.json b/packages/server/package.json index bda671e..ac88125 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -2,7 +2,7 @@ "name": "@feiyun/server", "repository": "https://github.com/hxg2050/feiyun.git", "private": false, - "version": "0.2.0", + "version": "0.2.1", "type": "module", "main": "./src/index.ts", "engines": {