From 7a8af935dd5d2898a2ae779daf2fdaa977d8750e Mon Sep 17 00:00:00 2001 From: youxia <675567585@qq.com> Date: Thu, 11 Jul 2024 03:01:18 +0700 Subject: [PATCH] fix: repair set socketId --- packages/feiyun/package.json | 2 +- packages/handler/package.json | 3 +-- packages/handler/src/index.ts | 2 +- packages/server/package.json | 2 +- packages/server/src/feiyun.ts | 4 ++-- packages/server/src/server.ts | 5 +---- pnpm-lock.yaml | 3 --- 7 files changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/feiyun/package.json b/packages/feiyun/package.json index 07d999c..f6a7a22 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.2.18", + "version": "0.2.19", "private": false, "type": "module", "main": "./src/index.ts", diff --git a/packages/handler/package.json b/packages/handler/package.json index c947b03..be20882 100644 --- a/packages/handler/package.json +++ b/packages/handler/package.json @@ -1,6 +1,6 @@ { "name": "@feiyun/handler", - "version": "0.0.28", + "version": "0.0.29", "license": "MIT", "type": "module", "main": "./src/index.ts", @@ -54,7 +54,6 @@ "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-typescript": "^11.1.6", "@types/node": "^20.11.19", - "feiyun": "workspace:^", "rollup": "^4.12.0", "rollup-plugin-ts": "^3.4.5", "tslib": "^2.6.2", diff --git a/packages/handler/src/index.ts b/packages/handler/src/index.ts index 31983db..51b55ab 100644 --- a/packages/handler/src/index.ts +++ b/packages/handler/src/index.ts @@ -4,7 +4,7 @@ import path from "node:path"; import { plainToInstance } from "class-transformer"; import { validate } from "class-validator"; -import type { Context, FeiyunMiddleware } from 'feiyun' +import type { Context, FeiyunMiddleware } from '@feiyun/server' const PATH_METADATA = 'path'; const METHOD_METADATA = 'method'; const PARAM_METADATA = 'param'; diff --git a/packages/server/package.json b/packages/server/package.json index 67af2ea..285dfd5 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.1.2", + "version": "0.1.3", "type": "module", "main": "./src/index.ts", "engines": { diff --git a/packages/server/src/feiyun.ts b/packages/server/src/feiyun.ts index 29cce49..0725714 100644 --- a/packages/server/src/feiyun.ts +++ b/packages/server/src/feiyun.ts @@ -50,9 +50,9 @@ export class Feiyun { client.close(); } this.server.handlerCallback = (client, data) => { - const ctx = new Context() - ctx.socket = client try { + const ctx = new Context() + ctx.socket = client const msg = JSON.parse(data) const [rid, route, reqData]: [number, string, any] = msg diff --git a/packages/server/src/server.ts b/packages/server/src/server.ts index 77d481d..d98b5d4 100644 --- a/packages/server/src/server.ts +++ b/packages/server/src/server.ts @@ -15,8 +15,6 @@ interface ServerConfig { export class Server implements IServer { handlers = new Map() - clientIndex: number = 0 - wss?: IWebsocketServer clientsFromServerWebSocket: Map = new Map(); @@ -40,8 +38,7 @@ export class Server implements IServer { }); this.wss.open((ws) => { const client = new Socket(this) - ws.data.socketId = client.id; - this.clients.set(this.clientIndex, ws) + this.clients.set(client.id, ws) this.clientsFromServerWebSocket.set(ws, client); }); this.wss.message((ws, data) => { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aaf7ad4..155e9f9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -92,9 +92,6 @@ importers: '@types/node': specifier: ^20.11.19 version: 20.11.26 - feiyun: - specifier: workspace:^ - version: link:../feiyun rollup: specifier: ^4.12.0 version: 4.12.0