1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-30 21:22:17 -05:00

make it possible to accept / reject calls

This commit is contained in:
Philipp Hancke 2014-04-22 09:59:28 +02:00
parent 0c738e5334
commit 4b04d706fe
4 changed files with 36 additions and 10 deletions

View File

@ -409,15 +409,10 @@ module.exports = function (client, app) {
state: 'incoming', state: 'incoming',
jingleSession: session jingleSession: session
}); });
if (!client.jingle.localStream) {
client.jingle.startLocalMedia(null, function (err) {
session.accept();
});
} else {
session.accept();
}
contact.jingleCall = call; contact.jingleCall = call;
contact.callState = 'incoming';
me.calls.add(call); me.calls.add(call);
// FIXME: send directed presence if not on roster
}); });
client.on('jingle:outgoing', function (session) { client.on('jingle:outgoing', function (session) {
@ -441,6 +436,7 @@ module.exports = function (client, app) {
client.on('jingle:accepted', function (session) { client.on('jingle:accepted', function (session) {
var contact = me.getContact(session.peer); var contact = me.getContact(session.peer);
contact.callState = 'activeCall'; contact.callState = 'activeCall';
console.log('jingle accepted...');
contact.onCall = true; contact.onCall = true;
}); });

View File

@ -30,6 +30,7 @@ module.exports = BasePage.extend({
'keydown textarea': 'handleKeyDown', 'keydown textarea': 'handleKeyDown',
'keyup textarea': 'handleKeyUp', 'keyup textarea': 'handleKeyUp',
'click .call': 'handleCallClick', 'click .call': 'handleCallClick',
'click .accept': 'handleAcceptClick',
'click .end': 'handleEndClick', 'click .end': 'handleEndClick',
'click .mute': 'handleMuteClick' 'click .mute': 'handleMuteClick'
}, },
@ -226,10 +227,38 @@ module.exports = BasePage.extend({
embedIt(newEl); embedIt(newEl);
this.lastModel = model; this.lastModel = model;
}, },
handleAcceptClick: function (e) {
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({
condition: 'decline'
});
} else {
self.model.jingleCall.jingleSession.accept();
}
});
} else {
this.model.jingleCall.jingleSession.accept();
}
}
return false;
},
handleEndClick: function (e) { handleEndClick: function (e) {
e.preventDefault(); e.preventDefault();
var condition = 'success';
if (this.model.jingleCall && this.model.jingleCall.jingleSession &&
this.model.jingleCall.jingleSession.state == 'pending') {
condition = 'decline';
}
this.model.jingleCall.end({ this.model.jingleCall.end({
condition: 'success' condition: condition
}); });
return false; return false;
}, },

View File

@ -470,7 +470,7 @@ exports.misc.growlMessage = function anonymous(locals) {
exports.pages.chat = function anonymous(locals) { exports.pages.chat = function anonymous(locals) {
var buf = []; var buf = [];
with (locals || {}) { with (locals || {}) {
buf.push('<section class="page chat"><section class="conversation"><header><h1><button class="primary small call">call</button><span class="name"></span><span class="status"></span></h1><div class="tzo"></div><div class="activeCall"><video autoplay="autoplay" class="remote"></video><video autoplay="autoplay" muted="muted" class="local"></video><aside class="button-wrap"><button class="end primary">End</button><div class="button-group outlined"><button class="mute">Mute</button><button class="unmute">Unmute</button></div></aside></div></header><ul class="messages scroll-container"></ul><div class="chatBox"><form><textarea name="chatInput" type="text" placeholder="Send a message..." autocomplete="off"></textarea></form></div></section></section>'); buf.push('<section class="page chat"><section class="conversation"><header><h1><button class="primary small call">call</button><span class="name"></span><span class="status"></span></h1><div class="tzo"></div><div class="activeCall"><video autoplay="autoplay" class="remote"></video><video autoplay="autoplay" muted="muted" class="local"></video><aside class="button-wrap"><button class="accept primary">Accept</button><button class="end secondary">End</button><div class="button-group outlined"><button class="mute">Mute</button><button class="unmute">Unmute</button></div></aside></div></header><ul class="messages scroll-container"></ul><div class="chatBox"><form><textarea name="chatInput" type="text" placeholder="Send a message..." autocomplete="off"></textarea></form></div></section></section>');
} }
return buf.join(""); return buf.join("");
}; };

View File

@ -10,7 +10,8 @@ section.page.chat
video.remote(autoplay) video.remote(autoplay)
video.local(autoplay, muted) video.local(autoplay, muted)
aside.button-wrap aside.button-wrap
button.end.primary End button.accept.primary Accept
button.end.secondary End
.button-group.outlined .button-group.outlined
button.mute Mute button.mute Mute
button.unmute Unmute button.unmute Unmute