From 026577bf88ea75586fcabdfa388d4749bc083827 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 1 Jun 2024 10:25:04 +0530 Subject: [PATCH] feat: add browser instace to pool --- .../browser-management/classes/BrowserPool.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/server/src/browser-management/classes/BrowserPool.ts b/server/src/browser-management/classes/BrowserPool.ts index 7332b1b1..df855ae0 100644 --- a/server/src/browser-management/classes/BrowserPool.ts +++ b/server/src/browser-management/classes/BrowserPool.ts @@ -39,4 +39,21 @@ export class BrowserPool { * Holds all the instances of remote browsers. */ private pool : PoolDictionary = {}; + + /** + * Adds a remote browser instance to the pool indexed by the id. + * @param id remote browser instance's id + * @param browser remote browser instance + * @param active states if the browser's instance is being actively used + */ + public addRemoteBrowser = (id: string, browser: RemoteBrowser, active: boolean = false): void => { + this.pool = { + ...this.pool, + [id]: { + browser, + active, + }, + } + logger.log('debug', `Remote browser with id: ${id} added to the pool`); + }; }