add online clients event
This commit is contained in:
@@ -10,6 +10,7 @@ import { SocketConnection } from './socket.entity';
|
||||
@Injectable()
|
||||
export class SocketService {
|
||||
private readonly logger = new Logger(SocketService.name);
|
||||
private readonly onlineClients = new Map<string, string>();
|
||||
|
||||
constructor(
|
||||
@InjectRepository(SocketConnection)
|
||||
@@ -75,4 +76,16 @@ export class SocketService {
|
||||
message: 'Success in sending to all clients!',
|
||||
};
|
||||
}
|
||||
|
||||
setOnlineClient(clientId: string, socketId: string) {
|
||||
this.onlineClients.set(clientId, socketId);
|
||||
}
|
||||
|
||||
removeOnlineClient(clientId: string) {
|
||||
this.onlineClients.delete(clientId);
|
||||
}
|
||||
|
||||
getOnlineClients(): string[] {
|
||||
return [...this.onlineClients.keys()];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user