feat: 更新WsProxyManager注册逻辑,添加isLogin参数并优化HTML响应处理

This commit is contained in:
2026-03-05 04:31:45 +08:00
parent bbdf9f087d
commit 2518f6bba3
2 changed files with 13 additions and 9 deletions

View File

@@ -134,7 +134,7 @@ export class WsProxyManager {
}
this.checkConnceted();
}
register(id: string, opts?: { ws: WebSocket; user: string, id?: string }) {
register(id: string, opts?: { ws: WebSocket; user: string, id?: string, isLogin: boolean }) {
if (this.wssMap.has(id)) {
const value = this.wssMap.get(id);
if (value) {
@@ -232,7 +232,7 @@ export class WsProxyManager {
logger.debug('之前的连接已关闭,复用注册 ID 连接 ws', id);
this.unregister(id);
await new Promise(resolve => setTimeout(resolve, 100));
const wsMessage = this.register(id, { ws: opts.ws, user: opts.user, id });
const wsMessage = this.register(id, { ws: opts.ws, user: opts.user, id, isLogin });
wsMessage.sendConnected();
return { wsMessage, isNew: false, id: id };
} else {
@@ -246,7 +246,7 @@ export class WsProxyManager {
realId = id + registryId;
logger.debug('未登录用户,使用临时注册 ID 连接 ws', realId);
}
const wsMessage = this.register(realId, { ws: opts.ws, user: opts.user, id: realId });
const wsMessage = this.register(realId, { ws: opts.ws, user: opts.user, id: realId, isLogin });
return { wsMessage, isNew: true, id: realId };
}
}