How Events Work
The Anam SDK uses an event-driven architecture where your application can listen for specific events and react accordingly. This allows you to:- Update your UI based on connection status
- Track conversation history in real-time
- Handle user interruptions gracefully
- Monitor stream quality and performance
1
Initialize Client
Create your Anam client with a session token
2
Add Event Listeners
Register listeners for the events you care about
3
React to Events
Update your UI and application state based on event data
4
Clean Up
Remove listeners when components unmount or sessions end
Available Events
Connection Events
These events track the connection lifecycle between your client and Anam’s streaming infrastructure:CONNECTION_ESTABLISHED
Fired when the WebRTC connection is successfully established.
CONNECTION_CLOSED
Fired when the connection is terminated.
Video Events
VIDEO_PLAY_STARTED
Fired when the first video frames begin playing. Ideal for removing loading indicators.
Conversation Events
These events help you track and respond to conversation flow:MESSAGE_HISTORY_UPDATED
Provides the complete conversation history each time a participant finishes speaking.
MESSAGE_STREAM_EVENT_RECEIVED
Provides real-time transcription updates as speech occurs.
Audio Events
INPUT_AUDIO_STREAM_STARTED
Fired when microphone input is successfully initialized.
Talk Stream Events
TALK_STREAM_INTERRUPTED
Fired when a user interrupts a TalkMessageStream
by speaking.