diff --git a/src/channel/browser.gateway.ts b/src/channel/browser.gateway.ts index 61a0ee1ca101a87f17ec3eee5bcb17944aa6b6a2..93754fc87c2ef343c5828a7a96b3314c0f08791f 100644 --- a/src/channel/browser.gateway.ts +++ b/src/channel/browser.gateway.ts @@ -65,6 +65,23 @@ export class BrowserGateway { return true; } + /** + * Handles the "close-browser" event, allowing a client to close the browser. + * + * @param client - The connected socket client. + * @returns A boolean indicating the success of closing the browser. + */ + @SubscribeMessage('close-browser') + @UseRequestContext() + public async closeBrowser(@ConnectedSocket() client: Socket) { + const channel = await this.channels.fromClientOrFail(client); + + await this.browserService.closeBrowserContext(channel.id); + this.server.to(channel.id).emit('close-browser'); + + return true; + } + /** * Handles the "move-mouse" event, allowing a client to move the mouse in the browser. *