mirror of
https://github.com/moparisthebest/kaiwa
synced 2024-11-24 18:22:21 -05:00
refine, send directed presence before session-accept
This commit is contained in:
parent
4b04d706fe
commit
9f6f45eb30
@ -431,12 +431,15 @@ module.exports = function (client, app) {
|
||||
contact.callState = '';
|
||||
contact.jingleCall = null;
|
||||
contact.onCall = false;
|
||||
if (me.calls.length == 1) { // this is the last call
|
||||
client.jingle.stopLocalMedia();
|
||||
client.jingle.localStream = null;
|
||||
}
|
||||
});
|
||||
|
||||
client.on('jingle:accepted', function (session) {
|
||||
var contact = me.getContact(session.peer);
|
||||
contact.callState = 'activeCall';
|
||||
console.log('jingle accepted...');
|
||||
contact.onCall = true;
|
||||
});
|
||||
|
||||
|
@ -231,20 +231,21 @@ module.exports = BasePage.extend({
|
||||
e.preventDefault();
|
||||
var self = this;
|
||||
|
||||
//if (!(this.model.jingleCall && this.model.jingleCall.jingleSession)) return;
|
||||
this.$('button.accept').prop('disabled', true);
|
||||
if (this.model.jingleCall.jingleSession.state == 'pending') {
|
||||
if (!client.jingle.localStream) {
|
||||
client.jingle.startLocalMedia(null, function (err) {
|
||||
if (err) {
|
||||
this.model.jingleCall.end({
|
||||
self.model.jingleCall.end({
|
||||
condition: 'decline'
|
||||
});
|
||||
} else {
|
||||
client.sendPresence({to: client.JID(self.model.jingleCall.jingleSession.peer) });
|
||||
self.model.jingleCall.jingleSession.accept();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
client.sendPresence({to: client.JID(this.model.jingleCall.jingleSession.peer) });
|
||||
this.model.jingleCall.jingleSession.accept();
|
||||
}
|
||||
}
|
||||
@ -253,13 +254,14 @@ module.exports = BasePage.extend({
|
||||
handleEndClick: function (e) {
|
||||
e.preventDefault();
|
||||
var condition = 'success';
|
||||
if (this.model.jingleCall && this.model.jingleCall.jingleSession &&
|
||||
this.model.jingleCall.jingleSession.state == 'pending') {
|
||||
if (this.model.jingleCall) {
|
||||
if (this.model.jingleCall.jingleSession && this.model.jingleCall.jingleSession.state == 'pending') {
|
||||
condition = 'decline';
|
||||
}
|
||||
this.model.jingleCall.end({
|
||||
condition: condition
|
||||
});
|
||||
}
|
||||
return false;
|
||||
},
|
||||
handleMuteClick: function (e) {
|
||||
|
Loading…
Reference in New Issue
Block a user