mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-15 12:23:51 +00:00
feat: add sessions stats endpoint
This commit is contained in:
committed by
Carlos Valente
parent
71c468d069
commit
82810f1cb1
@@ -33,6 +33,7 @@ export class SocketServer implements IAdapter {
|
||||
|
||||
private wss: WebSocketServer | null;
|
||||
private readonly clients: Map<string, Client>;
|
||||
private lastConnection: Date | null = null;
|
||||
|
||||
constructor() {
|
||||
if (instance) {
|
||||
@@ -58,6 +59,7 @@ export class SocketServer implements IAdapter {
|
||||
path: '',
|
||||
});
|
||||
|
||||
this.lastConnection = new Date();
|
||||
logger.info(LogOrigin.Client, `${this.clients.size} Connections with new: ${clientId}`);
|
||||
|
||||
ws.send(
|
||||
@@ -171,6 +173,13 @@ export class SocketServer implements IAdapter {
|
||||
});
|
||||
}
|
||||
|
||||
getStats() {
|
||||
return {
|
||||
connectedClients: this.clients.size,
|
||||
lastConnection: this.lastConnection,
|
||||
};
|
||||
}
|
||||
|
||||
private sendClientList(): void {
|
||||
const payload = Object.fromEntries(this.clients.entries());
|
||||
this.sendAsJson({ type: 'client-list', payload });
|
||||
|
||||
Reference in New Issue
Block a user