Making calls

Please be sure that you are familiar with the SDK initialization before you continue with this part, since we will be assuming that you have SDK already initialized and connected to the VoxImplant Cloud.

After the SDK was initialized and connected to the VoxImplant Cloud it's now time to make your first call. Since the call can end in different ways there is a group of the call events that can be dispatched by the Call class instance. The call function of the VoxImplant.Client class is used to make an outgoing call from the SDK.

  1. var currentCall;
  2. currentCall = voximplant.call("numbertocall");
  3. /* Add event listeners */
  4. currentCall.addEventListener(VoxImplant.CallEvents.Connected, onCallConnected);
  5. currentCall.addEventListener(VoxImplant.CallEvents.Disconnected, onCallDisconnected);
  6. currentCall.addEventListener(VoxImplant.CallEvents.Failed, onCallFailed);
  7. currentCall.addEventListener(VoxImplant.CallEvents.ProgressToneStart, onProgressToneStart);
  8. currentCall.addEventListener(VoxImplant.CallEvents.ProgressToneStop, onProgressToneStop);
  9. /* Event handlers */
  10. function onCallConnected(event) {
  11. // event - the instance of VoxImplant.CallEvents.Connected class, use event.call to get the instance of VoxImplant.Call for this call
  12. // call was connected succesfully
  13. }
  14. function onCallDisconnected(event) {
  15. // event - the instance of VoxImplant.CallEvents.Disconnected class, use event.call to get the instance of VoxImplant.Call for this call
  16. // call was disconnected
  17. }
  18. function onCallFailed(event) {
  19. // event - the instance of VoxImplant.CallEvents.Failed class, use event.call to get the instance of VoxImplant.Call for this call, or event.code and event.reason to get the status code and the reason of the call failure
  20. // call failed
  21. }
  22. function onProgressToneStart(event) {
  23. // event - the instance of VoxImplant.CallEvents.ProgressToneStart class, use event.call to get the instance of VoxImplant.Call for this call
  24. // Event dispatched when progress tone playback starts
  25. }
  26. function onProgressToneStop(event) {
  27. // event - the instance of VoxImplant.CallEvents.ProgressToneStop class, use event.call to get the instance of VoxImplant.Call for this call
  28. // Event dispatched when progress tone playback stops
  29. }

Manage calls

The SDK allows you to make different number of outgoing calls which can be controlled on both SDK and VoxEngine side. There are a few functions to control calls on the SDK side and it's a good idea to have access to each call instance via some variable. The list of the functions is available at VoxImplant.Call page from the Web SDK Reference. Here are just a few simple examples:

  1. currentCall.muteMicrophone(); // don't send audio from microphone to the call
  2. currentCall.sendTone("0"); // send tone for 0 key
  3. currentCall.unmuteMicrophone(); // start sending audio from microphone to the call
  4. currentCall.hangup(); // hangup the call