The Call Service Handler
Every calling bot requires an implementation of the ICallServiceHandler interface. This interface requires two methods, namely CallInitializedAsync
and CallCleanupAsync
. These methods are called when a new call object has been created and destroyed by the SDK respectively. The implementation of this interface is set in the IEnterprisePlatform
when creating it using the SetCallServiceHandler method on EnterprisePlatformBuilder
.
CallInitializedAsync
This method is called whenever a new call object has been created by the SDK. This can happen either through the CallService.CreateCallAsync methods, or by the SDK when an incoming call is detected. The bot needs to fill up a CallDescription object for that particular call which tells the SDK how to handle the call. Different overloads for the constructor of CallDescriptor sets up the call as a call with Locally Hosted Media or Remotely Hosted Media. Creating an instance of the Call Handler for the call can be done within the CallInitializedAsync
callback.
Important
Providing IMediaSession
while creating CallDescription
object means that the call itself is a Local Media call and the bot handles the low level IAudioSocket
and IVideoSocket
objects. For more details on Local Media calls, please see the article on calls with locally hosted media
CallCleanupAsync
This method is called whenever a call is being cleaned up by the SDK. In samples, this method is used to destroy the CallHandler
objects as the call does not exist beyond this.