bug fixed
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { Injectable, OnModuleInit } from '@nestjs/common';
|
||||
import { createClient } from 'redis';
|
||||
import { createClient, RedisClientType } from 'redis';
|
||||
|
||||
@Injectable()
|
||||
export class RedisService implements OnModuleInit {
|
||||
private client;
|
||||
private client: RedisClientType;
|
||||
|
||||
async onModuleInit() {
|
||||
this.client = createClient({
|
||||
|
||||
@@ -34,7 +34,7 @@ export class SocketGateway implements OnGatewayConnection {
|
||||
|
||||
await this.socketService.clientConnection({
|
||||
user_id: token.user_id,
|
||||
telephone_id: token.telephone_id,
|
||||
telephone_id: String(token.telephone_id),
|
||||
socket_id: client.id,
|
||||
event: 'connected',
|
||||
});
|
||||
@@ -46,7 +46,7 @@ export class SocketGateway implements OnGatewayConnection {
|
||||
client.on('disconnect', async (reason) => {
|
||||
await this.socketService.clientConnection({
|
||||
user_id: token.user_id,
|
||||
telephone_id: token.telephone_id,
|
||||
telephone_id: String(token.telephone_id),
|
||||
socket_id: client.id,
|
||||
event: 'disconnected',
|
||||
description: reason,
|
||||
|
||||
@@ -10,7 +10,7 @@ import { RedisService } from 'src/redis/redis.service';
|
||||
|
||||
export interface ClientToken {
|
||||
user_id: number;
|
||||
telephone_id: string;
|
||||
telephone_id: number;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
@@ -110,7 +110,7 @@ export class SocketService {
|
||||
async getAllOnlineClients(): Promise<ClientToken[]> {
|
||||
const client = this.redisService.getClient();
|
||||
const keys = await client.keys('online_clients:*');
|
||||
return keys.map((key) => {
|
||||
return keys.map((key: string) => {
|
||||
const [user_id, telephone_id] = key.split(':')[1].split('-').map(Number);
|
||||
return { user_id, telephone_id };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user