From 3904a782c7885611da3d63126dbbd20a35909d6f Mon Sep 17 00:00:00 2001 From: moyin <244344649@qq.com> Date: Fri, 9 Jan 2026 17:46:12 +0800 Subject: [PATCH] =?UTF-8?q?api=EF=BC=9A=E6=9B=B4=E6=96=B0WebSocket?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新WebSocket URL为统一的/game路径 - 添加协议类型和路径信息 - 移除未使用的ZulipWebSocketGateway导入 - 完善WebSocket连接信息的API响应 --- src/business/zulip/chat.controller.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/business/zulip/chat.controller.ts b/src/business/zulip/chat.controller.ts index dad654d..433b2ba 100644 --- a/src/business/zulip/chat.controller.ts +++ b/src/business/zulip/chat.controller.ts @@ -42,7 +42,6 @@ import { } from '@nestjs/swagger'; import { JwtAuthGuard } from '../auth/jwt_auth.guard'; import { ZulipService } from './zulip.service'; -import { ZulipWebSocketGateway } from './zulip_websocket.gateway'; import { CleanWebSocketGateway } from './clean_websocket.gateway'; import { SendChatMessageDto, @@ -106,7 +105,7 @@ export class ChatController { // 注意:这里需要一个有效的 socketId,但 REST API 没有 WebSocket 连接 // 这是一个限制,实际使用中应该通过 WebSocket 发送消息 throw new HttpException( - '聊天消息发送需要通过 WebSocket 连接。请使用 WebSocket 接口:ws://localhost:3000/game', + '聊天消息发送需要通过 WebSocket 连接。请使用 WebSocket 接口:wss://whaletownend.xinghangee.icu', HttpStatus.BAD_REQUEST, ); @@ -318,7 +317,7 @@ export class ChatController { properties: { websocketUrl: { type: 'string', - example: 'ws://localhost:3000/game', + example: 'wss://whaletownend.xinghangee.icu/game', description: 'WebSocket 连接地址' }, namespace: { @@ -347,7 +346,9 @@ export class ChatController { }) async getWebSocketInfo() { return { - websocketUrl: 'ws://localhost:3001', + websocketUrl: 'wss://whaletownend.xinghangee.icu/game', + protocol: 'native-websocket', + path: '/game', namespace: '/', supportedEvents: [ 'login', // 用户登录