How do I change a person's status (setPresenceState) after the user accepts a call? I need to set the state to "busy" for the person.
I think I can set the presence to busy when the "enterState:active" event fires, but how exactly do I do that?
How do I change a person's status (setPresenceState) after the user accepts a call? I need to set the state to "busy" for the person.
I think I can set the presence to busy when the "enterState:active" event fires, but how exactly do I do that?
In our documentation, we say that we automatically set the presence state to 'busy', when on a call, but looking through our code, it looks like we're currently not doing that. I'll fix that, but in the meantime I'll give an example of how you can do this yourself (in case you wanted to have some other behavior).
The general idea is to set the presence state to busy when the vline.MediaSession
goes into the active
state. In this example, client
is assumed to be the logged-in vline.Client
and session
is assumed to be the vline.Session
returned after logging in.
client.on('add:mediaSession', function(event) {
var mediaSession = event.target;
mediaSession.on('enterState:active', function() {
session.setPresence('busy');
}, this);
mediaSession.on('enterState:closed', function() {
session.setPresence('online');
}, this);
}, this);
The PresenceStates "busy" don't work, anything u want to do.. I use the "do_not_disturb" PresenceStates, instead of, and reset the state of "do_not_disturb" , even if the media session is 'disconnected' or broke by client or person.
You get it?
add this code instead of :
//----------------------------------------------------------------
client.on('add:mediaSession', function(event) {
var mediaSession = event.target;
mediaSession.on('enterState:active', function() {
session.setPresence('do_not_disturb');
}, this);
mediaSession.on('enterState:closed', function() {
session.setPresence('online');
}, this);
mediaSession.on('enterState:outgoing', function() {
session.setPresence('do_not_disturb');
}, this);
mediaSession.on('enterState:incoming', function() {
session.setPresence('do_not_disturb');
}, this);
mediaSession.on('enterState:disconnected', function() {
session.setPresence('online');
}, this);
}, this);
//----------------------------------------------------------------
To reset the state of 'do_not_disturb', what event happen, and even if client or person, have broke the session, just add this code after :
// fetch person object associated with username: session.getPerson(userId).done(function(person) {
session.setPresence('online');
( vline.MediaSession is assumed to be into the active state. session is assumed to be the vline.Session returned after logging in.)