How do you configure a client to auto-answer within vLine?

570 Views Asked by At

What is the correct method for setting a client to auto answer with the vLine API for WebRTC calls?

1

There are 1 best solutions below

0
On

Looking at your comment, it looks like you have figured this out. But for completeness and for future reference I will go ahead and answer.

To auto answer a call, all you have to do is call MediaSession.start() when an incoming call comes in, instead of throwing a prompt to the user.

Here is an example snippet:

client.on('add:mediaSession', onAddMediaSession, self);

// Handle new media sessions
onAddMediaSession(event){
  var mediaSession = event.target;
  mediaSession.on('enterState:incoming', onIncoming, self);
},

// Handle new incoming calls and autoAccept
onIncoming(event){
  var mediaSession = event.target;

  // Auto Accept call instead of a prompt
  mediaSession.start();
}

Note that you can do this in your code even if you are using the UI Widgets.