1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-21 16:55:10 -05:00

refine, send directed presence before session-accept

This commit is contained in:
Philipp Hancke 2014-04-22 11:16:10 +02:00
parent 4b04d706fe
commit 9f6f45eb30
2 changed files with 14 additions and 9 deletions

View File

@ -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;
});

View File

@ -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') {
condition = 'decline';
if (this.model.jingleCall) {
if (this.model.jingleCall.jingleSession && this.model.jingleCall.jingleSession.state == 'pending') {
condition = 'decline';
}
this.model.jingleCall.end({
condition: condition
});
}
this.model.jingleCall.end({
condition: condition
});
return false;
},
handleMuteClick: function (e) {