websocket:统一WebSocket网关配置
- 为CleanWebSocketGateway添加/game路径配置 - 支持通过环境变量WEBSOCKET_PORT配置端口 - 移除ZulipWebSocketGateway的模块引用 - 统一使用CleanWebSocketGateway作为唯一WebSocket网关 - 更新模块注释,反映当前架构
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user