From 7c425490805a837b8b4d5b38547f05f240f849e3 Mon Sep 17 00:00:00 2001 From: ao-anam Date: Mon, 16 Jun 2025 11:03:21 +0100 Subject: [PATCH 1/2] feat: emit session ready signal --- src/modules/StreamingClient.ts | 6 +++++- src/types/events/public/AnamEvent.ts | 1 + src/types/events/public/EventCallbacks.ts | 1 + src/types/signalling/SignalMessage.ts | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/StreamingClient.ts b/src/modules/StreamingClient.ts index 92a69f0..2060bf1 100644 --- a/src/modules/StreamingClient.ts +++ b/src/modules/StreamingClient.ts @@ -282,9 +282,13 @@ export class StreamingClient { chatMessage.correlationId, ); break; + case SignalMessageAction.SESSION_READY: + const sessionId = signalMessage.sessionId as string; + this.publicEventEmitter.emit(AnamEvent.SESSION_READY, sessionId); + break; default: console.error( - 'StreamingClient - onSignalMessage: unknown signal message action type', + 'StreamingClient - onSignalMessage: unknown signal message action type. Is your anam-sdk version up to date?', signalMessage, ); } diff --git a/src/types/events/public/AnamEvent.ts b/src/types/events/public/AnamEvent.ts index b365166..441317d 100644 --- a/src/types/events/public/AnamEvent.ts +++ b/src/types/events/public/AnamEvent.ts @@ -8,4 +8,5 @@ export enum AnamEvent { VIDEO_PLAY_STARTED = 'VIDEO_PLAY_STARTED', AUDIO_STREAM_STARTED = 'AUDIO_STREAM_STARTED', TALK_STREAM_INTERRUPTED = 'TALK_STREAM_INTERRUPTED', + SESSION_READY = 'SESSION_READY', } diff --git a/src/types/events/public/EventCallbacks.ts b/src/types/events/public/EventCallbacks.ts index a647c64..557f280 100644 --- a/src/types/events/public/EventCallbacks.ts +++ b/src/types/events/public/EventCallbacks.ts @@ -12,4 +12,5 @@ export type EventCallbacks = { [AnamEvent.VIDEO_PLAY_STARTED]: () => void; [AnamEvent.AUDIO_STREAM_STARTED]: (audioStream: MediaStream) => void; [AnamEvent.TALK_STREAM_INTERRUPTED]: (correlationId: string) => void; + [AnamEvent.SESSION_READY]: (sessionId: string) => void; }; diff --git a/src/types/signalling/SignalMessage.ts b/src/types/signalling/SignalMessage.ts index 7052fbf..0fa26b0 100644 --- a/src/types/signalling/SignalMessage.ts +++ b/src/types/signalling/SignalMessage.ts @@ -7,6 +7,7 @@ export enum SignalMessageAction { WARNING = 'warning', TALK_STREAM_INTERRUPTED = 'talkinputstreaminterrupted', TALK_STREAM_INPUT = 'talkstream', + SESSION_READY = 'sessionready', } export interface SignalMessage { From 0724548a44295deef9dec19b8b038ffbce2f90a6 Mon Sep 17 00:00:00 2001 From: ao-anam Date: Mon, 16 Jun 2025 11:06:18 +0100 Subject: [PATCH 2/2] feat: emit server warnings as events --- src/modules/StreamingClient.ts | 1 + src/types/events/public/AnamEvent.ts | 1 + src/types/events/public/EventCallbacks.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/src/modules/StreamingClient.ts b/src/modules/StreamingClient.ts index 2060bf1..f808fc6 100644 --- a/src/modules/StreamingClient.ts +++ b/src/modules/StreamingClient.ts @@ -273,6 +273,7 @@ export class StreamingClient { case SignalMessageAction.WARNING: const message = signalMessage.payload as string; console.warn('Warning received from server: ' + message); + this.publicEventEmitter.emit(AnamEvent.SERVER_WARNING, message); break; case SignalMessageAction.TALK_STREAM_INTERRUPTED: const chatMessage = diff --git a/src/types/events/public/AnamEvent.ts b/src/types/events/public/AnamEvent.ts index 441317d..fd02179 100644 --- a/src/types/events/public/AnamEvent.ts +++ b/src/types/events/public/AnamEvent.ts @@ -9,4 +9,5 @@ export enum AnamEvent { AUDIO_STREAM_STARTED = 'AUDIO_STREAM_STARTED', TALK_STREAM_INTERRUPTED = 'TALK_STREAM_INTERRUPTED', SESSION_READY = 'SESSION_READY', + SERVER_WARNING = 'SERVER_WARNING', } diff --git a/src/types/events/public/EventCallbacks.ts b/src/types/events/public/EventCallbacks.ts index 557f280..74b73c3 100644 --- a/src/types/events/public/EventCallbacks.ts +++ b/src/types/events/public/EventCallbacks.ts @@ -13,4 +13,5 @@ export type EventCallbacks = { [AnamEvent.AUDIO_STREAM_STARTED]: (audioStream: MediaStream) => void; [AnamEvent.TALK_STREAM_INTERRUPTED]: (correlationId: string) => void; [AnamEvent.SESSION_READY]: (sessionId: string) => void; + [AnamEvent.SERVER_WARNING]: (message: string) => void; };