websocket:统一WebSocket网关配置

- 为CleanWebSocketGateway添加/game路径配置
- 支持通过环境变量WEBSOCKET_PORT配置端口
- 移除ZulipWebSocketGateway的模块引用
- 统一使用CleanWebSocketGateway作为唯一WebSocket网关
- 更新模块注释,反映当前架构
This commit is contained in:
moyin
2026-01-09 17:45:51 +08:00
parent 5f662ef091
commit 75ac7ac0f8
2 changed files with 13 additions and 5 deletions

View File

@@ -31,9 +31,12 @@ export class CleanWebSocketGateway implements OnModuleInit, OnModuleDestroy {
) {}
async onModuleInit() {
const port = 3001;
const port = process.env.WEBSOCKET_PORT ? parseInt(process.env.WEBSOCKET_PORT) : 3001;
this.server = new WebSocket.Server({ port });
this.server = new WebSocket.Server({
port,
path: '/game' // 统一使用 /game 路径
});
this.server.on('connection', (ws: ExtendedWebSocket) => {
ws.id = this.generateClientId();
@@ -71,7 +74,7 @@ export class CleanWebSocketGateway implements OnModuleInit, OnModuleDestroy {
});
});
this.logger.log(`WebSocket服务器启动成功端口: ${port}`);
this.logger.log(`WebSocket服务器启动成功端口: ${port},路径: /game`);
}
async onModuleDestroy() {