From f8cf4c5c9c23af3ef5b7d3f21f7bf48f17e110ce Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 18 Apr 2020 12:27:39 +0200 Subject: [PATCH] Can close all active websockets of a user --- src/controllers/UserWebSocketController.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/controllers/UserWebSocketController.ts b/src/controllers/UserWebSocketController.ts index 94afdae..d0fdd17 100644 --- a/src/controllers/UserWebSocketController.ts +++ b/src/controllers/UserWebSocketController.ts @@ -220,6 +220,16 @@ export class UserWebSocketController { entry.ws.close(); } + /** + * Close all user websockets + * + * @param userID Target user ID + */ + public static async CloseAllUserSockets(userID: number) { + for(const entry of this.active_clients.filter((f) => f.userID == userID)) + entry.ws.close(); + } + /** * Send a message to a socket *