Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: repair set socketId #5

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/feiyun/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 1 addition & 2 deletions packages/handler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@feiyun/handler",
"version": "0.0.28",
"version": "0.0.29",
"license": "MIT",
"type": "module",
"main": "./src/index.ts",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/handler/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/feiyun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions packages/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ interface ServerConfig {
export class Server implements IServer {
handlers = new Map<string, Handler>()

clientIndex: number = 0

wss?: IWebsocketServer<WebSocketData>

clientsFromServerWebSocket: Map<SWS, Socket> = new Map();
Expand All @@ -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) => {
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading