From 2b6a9922078d8de966f0b184d8c8ac92fe0e9aff Mon Sep 17 00:00:00 2001 From: Filipi Fuchter Date: Thu, 30 Jan 2025 09:37:33 -0300 Subject: [PATCH] Sending the app-message to start playing audio once the track has started. --- .../client/react-native/src/App.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/examples/bot-ready-signalling/client/react-native/src/App.js b/examples/bot-ready-signalling/client/react-native/src/App.js index 85b10bec4..5b9e439f9 100644 --- a/examples/bot-ready-signalling/client/react-native/src/App.js +++ b/examples/bot-ready-signalling/client/react-native/src/App.js @@ -30,7 +30,26 @@ const CallScreen = () => { setIsConnected(false); log('Client disconnected'); }); + callObject.on("participant-left", () => { + // When the bot leaves, we are also disconnecting from the call + disconnect().catch((err) => { + log(`Failed to disconnect ${err}`); + }) + }); callObject.on("error", (evt) => log(`Error: ${evt.error}`)); + // Other events just for awareness + callObject.on("track-started", (evt) => { + handleEventToConsole(evt) + log("Will send the audio message to play the audio at the next tick") + callObject.sendAppMessage("playable") + }); + callObject.on("track-stopped", handleEventToConsole); + callObject.on("participant-joined", handleEventToConsole); + callObject.on("participant-updated", handleEventToConsole); + }; + + const handleEventToConsole = (evt) => { + log(`Received event: ${evt.action}`); }; const connect = async () => { @@ -72,7 +91,6 @@ const CallScreen = () => { Debug Info - Debug logs will appear here... {logs.map((logEntry, index) => ( {logEntry}