|
@@ -2,7 +2,7 @@
|
|
|
import { EVENT, CODEMEG } from "../../enum/index.js";
|
|
|
import { updateUser, removeRoomAllUsers, getAllRoomUsers, updateRoomUser } from "../../service/userService.js";
|
|
|
import { setRoomConfig, getRoomConfig } from "../../service/roomConfigService.js";
|
|
|
-
|
|
|
+import { subClient } from "../../connection/redis.js";
|
|
|
export class RoomAssistant {
|
|
|
constructor(socket, redis, room) {
|
|
|
this.socket = socket;
|
|
@@ -214,4 +214,23 @@ export class RoomAssistant {
|
|
|
await this.redis.del(syncId);
|
|
|
await this.redis.del(userId);
|
|
|
}
|
|
|
+ // RoomSessionId 房间有效时间
|
|
|
+ setRoomUnlimit(roomSessionId) {
|
|
|
+ return this.redis.expire(roomSessionId, -1);
|
|
|
+ }
|
|
|
+ setRoomAvailableBySeconds(roomSessionId, seconds) {
|
|
|
+ return this.redis.expire(roomSessionId, seconds);
|
|
|
+ }
|
|
|
+ setRoomAvailableByHours(roomSessionId, hours) {
|
|
|
+ return this.redis.expire(roomSessionId, 60 * 60 * hours);
|
|
|
+ }
|
|
|
+ watchRoomExpired(callback) {
|
|
|
+ subClient.subscribe("__keyevent@0__:expired", this.watchRoomExpiredFn);
|
|
|
+ }
|
|
|
+ watchRoomExpiredFn(key) {
|
|
|
+ console.log("key=> ", key);
|
|
|
+ }
|
|
|
+ unWatchRoomExpired() {
|
|
|
+ subClient.unsubscribe("__keyevent@0__:expired", this.watchRoomExpiredFn);
|
|
|
+ }
|
|
|
}
|