Skip to content

Commit 089b64a

Browse files
authored
Merge pull request #113 from anam-org/alpha
feat: session ready event
2 parents 504ead5 + e33293f commit 089b64a

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

src/modules/StreamingClient.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ export class StreamingClient {
273273
case SignalMessageAction.WARNING:
274274
const message = signalMessage.payload as string;
275275
console.warn('Warning received from server: ' + message);
276+
this.publicEventEmitter.emit(AnamEvent.SERVER_WARNING, message);
276277
break;
277278
case SignalMessageAction.TALK_STREAM_INTERRUPTED:
278279
const chatMessage =
@@ -282,9 +283,13 @@ export class StreamingClient {
282283
chatMessage.correlationId,
283284
);
284285
break;
286+
case SignalMessageAction.SESSION_READY:
287+
const sessionId = signalMessage.sessionId as string;
288+
this.publicEventEmitter.emit(AnamEvent.SESSION_READY, sessionId);
289+
break;
285290
default:
286291
console.error(
287-
'StreamingClient - onSignalMessage: unknown signal message action type',
292+
'StreamingClient - onSignalMessage: unknown signal message action type. Is your anam-sdk version up to date?',
288293
signalMessage,
289294
);
290295
}

src/types/events/public/AnamEvent.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ export enum AnamEvent {
88
VIDEO_PLAY_STARTED = 'VIDEO_PLAY_STARTED',
99
AUDIO_STREAM_STARTED = 'AUDIO_STREAM_STARTED',
1010
TALK_STREAM_INTERRUPTED = 'TALK_STREAM_INTERRUPTED',
11+
SESSION_READY = 'SESSION_READY',
12+
SERVER_WARNING = 'SERVER_WARNING',
1113
}

src/types/events/public/EventCallbacks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ export type EventCallbacks = {
1212
[AnamEvent.VIDEO_PLAY_STARTED]: () => void;
1313
[AnamEvent.AUDIO_STREAM_STARTED]: (audioStream: MediaStream) => void;
1414
[AnamEvent.TALK_STREAM_INTERRUPTED]: (correlationId: string) => void;
15+
[AnamEvent.SESSION_READY]: (sessionId: string) => void;
16+
[AnamEvent.SERVER_WARNING]: (message: string) => void;
1517
};

src/types/signalling/SignalMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export enum SignalMessageAction {
77
WARNING = 'warning',
88
TALK_STREAM_INTERRUPTED = 'talkinputstreaminterrupted',
99
TALK_STREAM_INPUT = 'talkstream',
10+
SESSION_READY = 'sessionready',
1011
}
1112

1213
export interface SignalMessage {

0 commit comments

Comments
 (0)