|
@@ -10,7 +10,7 @@ export class UsersService {
|
|
@InjectRedis() private readonly redis: Redis,
|
|
@InjectRedis() private readonly redis: Redis,
|
|
@Inject(forwardRef(() => RoomService))
|
|
@Inject(forwardRef(() => RoomService))
|
|
private roomService: RoomService,
|
|
private roomService: RoomService,
|
|
- ) { }
|
|
|
|
|
|
+ ) {}
|
|
|
|
|
|
async isUserInRooms(RoomId: string, UserId: string): Promise<boolean> {
|
|
async isUserInRooms(RoomId: string, UserId: string): Promise<boolean> {
|
|
const res = await this.redis.hexists(
|
|
const res = await this.redis.hexists(
|
|
@@ -112,6 +112,7 @@ export class UsersService {
|
|
async setRoomConfig(
|
|
async setRoomConfig(
|
|
RoomId: string,
|
|
RoomId: string,
|
|
RoomConfig: RoomConfigType,
|
|
RoomConfig: RoomConfigType,
|
|
|
|
+ socket?: Socket,
|
|
): Promise<void> {
|
|
): Promise<void> {
|
|
const isExist = await this.redis.hget(`kankan:socket:roomConfig`, RoomId);
|
|
const isExist = await this.redis.hget(`kankan:socket:roomConfig`, RoomId);
|
|
// console.log('setRoomConfig', isExist);
|
|
// console.log('setRoomConfig', isExist);
|
|
@@ -125,12 +126,20 @@ export class UsersService {
|
|
`'正常设置房间-ttl: ${RoomConfig.ttl}`,
|
|
`'正常设置房间-ttl: ${RoomConfig.ttl}`,
|
|
'room-ttl',
|
|
'room-ttl',
|
|
);
|
|
);
|
|
- await this.redis.set(
|
|
|
|
- `kankan:socket:tempRoom:${RoomId}`,
|
|
|
|
- '',
|
|
|
|
- 'EX',
|
|
|
|
- RoomConfig.ttl,
|
|
|
|
- );
|
|
|
|
|
|
+ if (RoomConfig.ttl > 0) {
|
|
|
|
+ await this.redis.set(
|
|
|
|
+ `kankan:socket:tempRoom:${RoomId}`,
|
|
|
|
+ '',
|
|
|
|
+ 'EX',
|
|
|
|
+ RoomConfig.ttl,
|
|
|
|
+ );
|
|
|
|
+ } else {
|
|
|
|
+ socket &&
|
|
|
|
+ socket.emit('manager-error', {
|
|
|
|
+ type: 'invalid-room-params',
|
|
|
|
+ code: 403,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if (isExist) {
|
|
if (isExist) {
|