feat: 更新WsProxyManager注册逻辑,添加isLogin参数并优化HTML响应处理
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user