优化
This commit is contained in:
@@ -7,7 +7,7 @@ import Offer from './offer';
|
||||
import Answer from './answer';
|
||||
import Candidate from './candidate';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { onGetAllConnectionIds, onGetOnlineUsers as onGetWsOnlineUsers, onGetRooms as onGetWsRooms } from './websockethandler';
|
||||
import { onGetAllConnectionIds, onGetOnlineUsers as onGetWsOnlineUsers, } from './websockethandler';
|
||||
import { log, LogLevel } from '../log';
|
||||
/**
|
||||
* 断开连接记录类
|
||||
@@ -996,57 +996,6 @@ function postCandidate(req: Request, res: Response): void {
|
||||
arr.push(candidate);
|
||||
res.sendStatus(200);
|
||||
}
|
||||
/**
|
||||
* @swagger
|
||||
* /signaling/rooms:
|
||||
* get:
|
||||
* summary: 获取房间和用户信息
|
||||
* description: 获取所有房间的信息,包括房间ID和链接的用户
|
||||
* security:
|
||||
* - sessionAuth: []
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 成功获取房间和用户信息
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* rooms:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* roomId:
|
||||
* type: string
|
||||
* description: 房间ID
|
||||
* users:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* sessionId:
|
||||
* type: string
|
||||
* description: 会话ID
|
||||
* connected:
|
||||
* type: boolean
|
||||
* description: 连接状态
|
||||
* userCount:
|
||||
* type: number
|
||||
* description: 用户数量
|
||||
* totalRooms:
|
||||
* type: number
|
||||
* description: 总房间数
|
||||
*/
|
||||
function onGetConnections(req: Request, res: Response): void {
|
||||
const connectionId = typeof req.query.connectionId === 'string' ? req.query.connectionId : undefined;
|
||||
const wsRooms = onGetWsRooms(connectionId).map((room) => ({
|
||||
...room,
|
||||
users: room.members
|
||||
}));
|
||||
|
||||
res.json({ rooms: wsRooms, totalRooms: wsRooms.length });
|
||||
}
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -1160,7 +1109,6 @@ export {
|
||||
postOffer, // 处理offer信令消息
|
||||
postAnswer, // 处理answer信令消息
|
||||
postCandidate, // 处理candidate信令消息
|
||||
onGetConnections, // 获取房间和用户信息
|
||||
getAllConnectionIds, // 获取所有连接ID
|
||||
getOnlineUsers // 获取在线WebSocket用户列表
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ const router: express.Router = express.Router();
|
||||
// 不需要会话ID的路由
|
||||
router.get('/connection-ids', handler.getAllConnectionIds);
|
||||
router.get('/users', handler.getOnlineUsers);
|
||||
router.get('/rooms', handler.onGetConnections);
|
||||
// router.get('/rooms', handler.onGetConnections);
|
||||
|
||||
// 需要会话ID的路由
|
||||
router.use(handler.checkSessionId);
|
||||
|
||||
Reference in New Issue
Block a user