Skip to content

Commit 66ec9e9

Browse files
author
Mayur
committed
feat: Removed methods- hasClientsInSession,getSessionInfo,abortAllSessions and getSessionAbortSignal
1 parent cb3bd81 commit 66ec9e9

File tree

1 file changed

+1
-40
lines changed

1 file changed

+1
-40
lines changed

apps/api/src/app/shared/services/websocket-service/websocket.service.ts

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,6 @@ export class WebSocketService implements OnGatewayConnection, OnGatewayDisconnec
110110
});
111111
}
112112

113-
// Get abort signal for a session
114-
getSessionAbortSignal(sessionId: string): AbortSignal | undefined {
115-
return this.sessionAbortControllers.get(sessionId)?.signal;
116-
}
117-
118113
// Use arrow functions to automatically bind 'this'
119114
sendProgress = (sessionId: string, progressData: IProgressData) => {
120115
if (!this.server) {
@@ -145,7 +140,7 @@ export class WebSocketService implements OnGatewayConnection, OnGatewayDisconnec
145140
error,
146141
timestamp: new Date().toISOString(),
147142
});
148-
this.logger.error(` Error sent to session ${sessionId}: ${error}`);
143+
this.logger.error(` Error sent to session ${sessionId}: ${error}`);
149144
} catch (err) {
150145
this.logger.error(`Failed to send error to session ${sessionId}:`, err);
151146
} finally {
@@ -172,38 +167,4 @@ export class WebSocketService implements OnGatewayConnection, OnGatewayDisconnec
172167
this.sessionAbortControllers.delete(sessionId);
173168
}
174169
};
175-
176-
// Helper method to check if a session has connected clients
177-
hasClientsInSession = async (sessionId: string): Promise<boolean> => {
178-
const room = this.server.sockets.adapter.rooms.get(sessionId);
179-
180-
return room && room.size > 0;
181-
};
182-
183-
// Method to get session info for debugging
184-
getSessionInfo = (sessionId: string) => {
185-
const room = this.server.sockets.adapter.rooms.get(sessionId);
186-
const hasAbortController = this.sessionAbortControllers.has(sessionId);
187-
const isAborted = this.sessionAbortControllers.get(sessionId)?.signal.aborted;
188-
189-
return {
190-
sessionId,
191-
clientCount: room ? room.size : 0,
192-
hasClients: room && room.size > 0,
193-
hasAbortController,
194-
isAborted,
195-
};
196-
};
197-
198-
// Method to manually abort all sessions (useful for cleanup)
199-
abortAllSessions() {
200-
this.logger.log('Aborting all active sessions');
201-
this.sessionAbortControllers.forEach((controller, sessionId) => {
202-
if (!controller.signal.aborted) {
203-
controller.abort();
204-
this.logger.log(`Aborted session ${sessionId}`);
205-
}
206-
});
207-
this.sessionAbortControllers.clear();
208-
}
209170
}

0 commit comments

Comments
 (0)