Managing calls

Managing a call state

There are 2 types of calls:

  1. An incoming call - a call that is made from some endpoint (Web SDK, a SIP phone, a PSTN network) to VoxImplant Cloud.
  2. An outgoing call - a call that originates in the VoxImplant Cloud.

Each call is represented by a Call object. Objects of this kind can't be instantiated by a developer directly. They are created automatically for incoming calls when a call arrives at VoxImplant. For an outgoing call, a corresponding object is created when VoxEngine.callPSTN, VoxEngine.callUser, or VoxEngine.callSIP is called.

The following basic call operations are available:

  1. Answer an incoming call - using Call.answer. This normally results in dispatching a CallEvents.Connected event
  2. Rejecting the incoming call - using Call.reject. This causes a CallEvents.Disconnected event
  3. Hanging up a call - using Call.hangup. This causes a CallEvents.Disconnected or CallEvents.Failedevent depending on the call state

Media control

A single session can handle multiple calls simultaneously, so VoxImplant will not be able to decide itself how to send media data between the calls. There are a couple functions that tell the Cloud how to route audio and video:

  1. Call.sendMediaTo, Call.stopMediaTo - tell the application whether to send media from one call to another call. This doesn't affect media sent in the other direction.
  2. VoxEngine.sendMediaBetween, VoxEngine.stopMediaBetween - these tell the application whether to send media between 2 calls.

Please note that each call can send media to multiple calls, but it can only receive media from one. So if you start playing a media file to a call, after the playback finished, that call will not receive audio even if the call was connected to another call before the playback started. Thus, you will need to use Call.sendMediaTo after the playback has finished (using the CallEvents.PlaybackFinished event).