From 461a1f1b702be4d1ae1aeca0c107ef6cd0600fa0 Mon Sep 17 00:00:00 2001 From: Timo K Date: Sat, 31 Jan 2026 12:29:56 +0100 Subject: [PATCH] add to sending room messages --- sdk/main.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sdk/main.ts b/sdk/main.ts index fc278c66..5625ba0d 100644 --- a/sdk/main.ts +++ b/sdk/main.ts @@ -88,6 +88,7 @@ interface MatrixRTCSdk { /** Use the LocalMemberConnectionState returned from `join` for a more detailed connection state */ connected$: Behavior; sendData?: (data: unknown) => Promise; + sendRoomMessage?: (message: string) => Promise; } export async function createMatrixRTCSdk( @@ -250,6 +251,16 @@ export async function createMatrixRTCSdk( } }; + const sendRoomMessage = async (message: string): Promise => { + const messageString = JSON.stringify(message); + logger.info("try sending to room: ", messageString); + try { + await client.sendTextMessage(room.roomId, message); + } catch (e) { + logger.error("failed sending to room: ", messageString, e); + } + }; + // after hangup gets called const leaveSubs = callViewModel.leave$.subscribe(() => { const scheduleWidgetCloseOnLeave = async (): Promise => { @@ -344,5 +355,6 @@ export async function createMatrixRTCSdk( [], ), sendData, + sendRoomMessage, }; }