api:更新WebSocket连接信息接口

- 更新WebSocket URL为统一的/game路径
- 添加协议类型和路径信息
- 移除未使用的ZulipWebSocketGateway导入
- 完善WebSocket连接信息的API响应
This commit is contained in:
moyin
2026-01-09 17:46:12 +08:00
parent 75ac7ac0f8
commit 3904a782c7

View File

@@ -42,7 +42,6 @@ import {
} from '@nestjs/swagger'; } from '@nestjs/swagger';
import { JwtAuthGuard } from '../auth/jwt_auth.guard'; import { JwtAuthGuard } from '../auth/jwt_auth.guard';
import { ZulipService } from './zulip.service'; import { ZulipService } from './zulip.service';
import { ZulipWebSocketGateway } from './zulip_websocket.gateway';
import { CleanWebSocketGateway } from './clean_websocket.gateway'; import { CleanWebSocketGateway } from './clean_websocket.gateway';
import { import {
SendChatMessageDto, SendChatMessageDto,
@@ -106,7 +105,7 @@ export class ChatController {
// 注意:这里需要一个有效的 socketId但 REST API 没有 WebSocket 连接 // 注意:这里需要一个有效的 socketId但 REST API 没有 WebSocket 连接
// 这是一个限制,实际使用中应该通过 WebSocket 发送消息 // 这是一个限制,实际使用中应该通过 WebSocket 发送消息
throw new HttpException( throw new HttpException(
'聊天消息发送需要通过 WebSocket 连接。请使用 WebSocket 接口ws://localhost:3000/game', '聊天消息发送需要通过 WebSocket 连接。请使用 WebSocket 接口wss://whaletownend.xinghangee.icu',
HttpStatus.BAD_REQUEST, HttpStatus.BAD_REQUEST,
); );
@@ -318,7 +317,7 @@ export class ChatController {
properties: { properties: {
websocketUrl: { websocketUrl: {
type: 'string', type: 'string',
example: 'ws://localhost:3000/game', example: 'wss://whaletownend.xinghangee.icu/game',
description: 'WebSocket 连接地址' description: 'WebSocket 连接地址'
}, },
namespace: { namespace: {
@@ -347,7 +346,9 @@ export class ChatController {
}) })
async getWebSocketInfo() { async getWebSocketInfo() {
return { return {
websocketUrl: 'ws://localhost:3001', websocketUrl: 'wss://whaletownend.xinghangee.icu/game',
protocol: 'native-websocket',
path: '/game',
namespace: '/', namespace: '/',
supportedEvents: [ supportedEvents: [
'login', // 用户登录 'login', // 用户登录