From 1dc8ac60233207c823e98785981d04bec7c4f177 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Thu, 25 Apr 2024 18:14:02 +0530 Subject: [PATCH] [web][cast] Close on sender disconnect --- web/apps/cast/src/pages/index.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/web/apps/cast/src/pages/index.tsx b/web/apps/cast/src/pages/index.tsx index cad6235ef..12c859e9c 100644 --- a/web/apps/cast/src/pages/index.tsx +++ b/web/apps/cast/src/pages/index.tsx @@ -64,6 +64,15 @@ export default function PairingMode() { "urn:x-cast:pair-request", messageReceiveHandler, ); + + // listen to close request and stop the context + context.addEventListener( + cast.framework.system.EventType.SENDER_DISCONNECTED, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + (_) => { + context.stop(); + }, + ); context.start(options); setIsCastReady(true); } catch (e) {