bug fixed

This commit is contained in:
AmirHossein Mahmoodi
2025-05-27 10:45:50 +03:30
parent ec28b21cf8
commit e17c7b899c
5 changed files with 18 additions and 6 deletions

View File

@@ -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({

View File

@@ -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,

View File

@@ -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 };
});