|
@@ -46,6 +46,15 @@ export class RoomController extends BasicController {
|
|
this.initBaseAction();
|
|
this.initBaseAction();
|
|
this.roomMasterAutoRejoin();
|
|
this.roomMasterAutoRejoin();
|
|
this.roomAssistant.watchRoomExpired();
|
|
this.roomAssistant.watchRoomExpired();
|
|
|
|
+ // setInterval(async () => {
|
|
|
|
+ // if ([FROMTYPE.Bridge].includes(Number(this.user.from))) {
|
|
|
|
+ // const AllRoomUsers = await getAllRoomUsers(this.roomId);
|
|
|
|
+ // this.socket.broadcast.to(this.roomId).emit(EVENT.roomStatus, {
|
|
|
|
+ // roomsPerson: AllRoomUsers,
|
|
|
|
+ // });
|
|
|
|
+ // console.log("定时测试", this.roomId);
|
|
|
|
+ // }
|
|
|
|
+ // }, 10000);
|
|
} catch (error) {
|
|
} catch (error) {
|
|
this.logger.error("roomController::run::error", error);
|
|
this.logger.error("roomController::run::error", error);
|
|
}
|
|
}
|
|
@@ -78,6 +87,7 @@ export class RoomController extends BasicController {
|
|
}
|
|
}
|
|
|
|
|
|
// 加入
|
|
// 加入
|
|
|
|
+ console.log("roomId", this.roomId);
|
|
this.socket.join(this.roomId);
|
|
this.socket.join(this.roomId);
|
|
} else {
|
|
} else {
|
|
this.logger.info("user-query-不存在 :", this.socket.handshake.query);
|
|
this.logger.info("user-query-不存在 :", this.socket.handshake.query);
|
|
@@ -170,20 +180,38 @@ export class RoomController extends BasicController {
|
|
});
|
|
});
|
|
|
|
|
|
this.socket.on(EVENT.kickUser, async ({ data, from }) => {
|
|
this.socket.on(EVENT.kickUser, async ({ data, from }) => {
|
|
- const userId = `user:${data.userId}`;
|
|
|
|
- const roomId = `room:${data.sceneNumber}:${data.roomId}`;
|
|
|
|
- this.logger.info("kickUser", data.userId, data.roomId);
|
|
|
|
- this.roomAssistant.kickPersion(roomId, userId);
|
|
|
|
- const currentUser = await getCurrentUser(userId, FROMTYPE.MiniAPP);
|
|
|
|
- this.roomAssistant.notifyUsersChange(roomId, currentUser);
|
|
|
|
- //TODO 如果踢人后 如何通知?
|
|
|
|
- this.socket.broadcast.to(roomId).emit(EVENT.beKicked, data);
|
|
|
|
|
|
+ try {
|
|
|
|
+ const userId = `user:${data.userId}`;
|
|
|
|
+ const roomId = `room:${data.sceneNumber}:${data.roomId}`;
|
|
|
|
+
|
|
|
|
+ const isKick = await this.roomAssistant.kickPersion(roomId, userId);
|
|
|
|
+ if (isKick) {
|
|
|
|
+ const AllRoomUsers = await getAllRoomUsers(roomId);
|
|
|
|
+ const currentUser = await getCurrentUser(userId, FROMTYPE.MiniAPP);
|
|
|
|
+ console.log("kickUser-AllRoomUsers", AllRoomUsers.length);
|
|
|
|
+ this.logger.info("kickUser", currentUser, userId, roomId);
|
|
|
|
+ // 通知管理
|
|
|
|
+ this.socket.emit(EVENT.someOneLeaveRoom, {
|
|
|
|
+ user: currentUser,
|
|
|
|
+ roomsPerson: AllRoomUsers,
|
|
|
|
+ });
|
|
|
|
+ // 通知房间人员变动
|
|
|
|
+ this.socket.broadcast.to(roomId).emit(EVENT.someOneLeaveRoom, {
|
|
|
|
+ user: currentUser,
|
|
|
|
+ roomsPerson: AllRoomUsers,
|
|
|
|
+ });
|
|
|
|
+ // 如果踢人后 如何通知?
|
|
|
|
+ this.socket.broadcast.to(roomId).emit(EVENT.beKicked, data);
|
|
|
|
+ }
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error("error", error);
|
|
|
|
+ }
|
|
});
|
|
});
|
|
|
|
|
|
if (this.debugger) {
|
|
if (this.debugger) {
|
|
this.socket.onAny((event, data) => {
|
|
this.socket.onAny((event, data) => {
|
|
if (event !== "webSyncAction") {
|
|
if (event !== "webSyncAction") {
|
|
- console.log(`onAny:get ${event}, data:${JSON.stringify(data)}`);
|
|
|
|
|
|
+ console.log(`onAny:get ${event}, data:${JSON.stringify(data)}`);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -197,7 +225,7 @@ export class RoomController extends BasicController {
|
|
const AllRoomUsers = await getAllRoomUsers(this.roomId);
|
|
const AllRoomUsers = await getAllRoomUsers(this.roomId);
|
|
// 房主
|
|
// 房主
|
|
if (this.isHoster(this.user.role)) {
|
|
if (this.isHoster(this.user.role)) {
|
|
- console.log("自动接连", this.roomId);
|
|
|
|
|
|
+ console.log("自动接连", this.roomId, this.user.from);
|
|
this.socket.join(this.roomId);
|
|
this.socket.join(this.roomId);
|
|
|
|
|
|
this.socket.emit("autoReJoin", {
|
|
this.socket.emit("autoReJoin", {
|