WebRTC Events
Overview of WebRTC event handling
Events
This page documents all available events in the InnoCalls RTC SDK. Events allow you to respond to call state changes and user actions during calls.
Version Differences:
- v1: Events have minimal parameters,
callIdonly available oncallStarted- v2: All events receive a
callobject with complete session data- v2: Introduces
callAnsweredandcallFailedevents (replacingcallMissed/callRejected)
V1 Events
Call Ringing Event
The callRinging event is triggered when your call starts ringing on the recipient's side (i.e., after dialing but before the call is answered).
Example
innocallsRTC.on('callRinging', () => {
console.log('callRinging')
// Note: No parameters provided in v1
})Call Started Event
The callStarted event is triggered when the call is answered, not when it is merely initiated.
You can use the callId provided to access the call using the appropriate credentials and endpoint.
Example
innocallsRTC.on('callStarted', (callId) => {
console.log('callStarted')
console.log({ callId })
})Call Missed Event
The callMissed event is triggered when an incoming call is missed (not answered before timing out or ending).
Example
innocallsRTC.on('callMissed', () => {
console.log('callMissed') // when you miss a call
})Call Rejected Event
The callRejected event is triggered when a call is cancelled or rejected by the user before being answered.
Example
innocallsRTC.on('callRejected', () => {
console.log('callRejected') // when you reject or cancel a call
})Call Ended Event
The callEnded event is triggered when a call is terminated (either by the user or the remote party).
Example
innocallsRTC.on('callEnded', () => {
console.log('callEnded')
})Call Held Event
The held event is triggered when a call is put on hold.
Example
innocallsRTC.on('held', () => {
console.log('held')
})Call Released (Unhold) Event
The released event is triggered when a call is taken off hold and resumed.
Example
innocallsRTC.on('released', () => {
console.log('released')
})Call Muted Event
The muted event is triggered when a call is muted.
Example
innocallsRTC.on('muted', () => {
console.log('muted')
})Call Unmuted Event
The unmuted event is triggered when a call is unmuted.
Example
innocallsRTC.on('unmuted', () => {
console.log('unmuted')
})Mounting the Dialpad
To mount the Dialpad, ensure that you have finished setting up all event listeners.
The Dialpad should be mounted to a specific element on your webpage, typically with an ID of root.
// Set up event listeners
innocallsRTC.on('callRinging', () => {
console.log('callRinging')
})
innocallsRTC.on('callStarted', (callId) => {
console.log('callStarted')
console.log({ callId })
})
innocallsRTC.on('callMissed', () => {
console.log('callMissed')
})
innocallsRTC.on('callRejected', () => {
console.log('callRejected')
})
innocallsRTC.on('callEnded', () => {
console.log('callEnded')
})
innocallsRTC.on('held', () => {
console.log('held')
})
innocallsRTC.on('released', () => {
console.log('released')
})
innocallsRTC.on('muted', () => {
console.log('muted')
})
innocallsRTC.on('unmuted', () => {
console.log('unmuted')
})
// Mount the Dialpad to the element with id="root"
innocallsRTC.mount('#root')