mirror of
https://github.com/moparisthebest/kaiwa
synced 2024-11-24 18:22:21 -05:00
Merge branch 'master' of github.com:andyet/otalk
This commit is contained in:
commit
d558ce82d5
@ -67,10 +67,6 @@ module.exports = {
|
||||
client.use(pushNotifications);
|
||||
xmppEventHandlers(self.api, self);
|
||||
|
||||
if (self.api.jingle.capabilities.length > 1) {
|
||||
self.api.jingle.startLocalMedia();
|
||||
}
|
||||
|
||||
self.api.once('session:started', function () {
|
||||
app.state.hasConnected = true;
|
||||
cb();
|
||||
|
@ -409,9 +409,10 @@ module.exports = function (client, app) {
|
||||
state: 'incoming',
|
||||
jingleSession: session
|
||||
});
|
||||
session.accept();
|
||||
contact.jingleCall = call;
|
||||
contact.callState = 'incoming';
|
||||
me.calls.add(call);
|
||||
// FIXME: send directed presence if not on roster
|
||||
});
|
||||
|
||||
client.on('jingle:outgoing', function (session) {
|
||||
@ -430,6 +431,10 @@ 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) {
|
||||
@ -449,11 +454,10 @@ module.exports = function (client, app) {
|
||||
client.on('jingle:remotestream:added', function (session) {
|
||||
var contact = me.getContact(session.peer);
|
||||
if (!contact) {
|
||||
contact = new Contact({jid: client.JID(session.peer).bare});
|
||||
contact.resources.add({id: session.peer});
|
||||
me.contacts.add(contact);
|
||||
}
|
||||
contact.stream = session.stream;
|
||||
contact.stream = session.streams[0];
|
||||
});
|
||||
|
||||
client.on('jingle:remotestream:removed', function (session) {
|
||||
|
@ -30,6 +30,7 @@ module.exports = BasePage.extend({
|
||||
'keydown textarea': 'handleKeyDown',
|
||||
'keyup textarea': 'handleKeyUp',
|
||||
'click .call': 'handleCallClick',
|
||||
'click .accept': 'handleAcceptClick',
|
||||
'click .end': 'handleEndClick',
|
||||
'click .mute': 'handleMuteClick'
|
||||
},
|
||||
@ -226,11 +227,41 @@ module.exports = BasePage.extend({
|
||||
embedIt(newEl);
|
||||
this.lastModel = model;
|
||||
},
|
||||
handleAcceptClick: function (e) {
|
||||
e.preventDefault();
|
||||
var self = this;
|
||||
|
||||
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) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
handleEndClick: function (e) {
|
||||
e.preventDefault();
|
||||
this.model.jingleCall.end({
|
||||
condition: 'success'
|
||||
});
|
||||
var condition = 'success';
|
||||
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) {
|
||||
|
@ -470,7 +470,7 @@ exports.misc.growlMessage = function anonymous(locals) {
|
||||
exports.pages.chat = function anonymous(locals) {
|
||||
var buf = [];
|
||||
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("");
|
||||
};
|
||||
|
@ -10,7 +10,8 @@ section.page.chat
|
||||
video.remote(autoplay)
|
||||
video.local(autoplay, muted)
|
||||
aside.button-wrap
|
||||
button.end.primary End
|
||||
button.accept.primary Accept
|
||||
button.end.secondary End
|
||||
.button-group.outlined
|
||||
button.mute Mute
|
||||
button.unmute Unmute
|
||||
|
@ -25,7 +25,7 @@
|
||||
"oembed": "0.1.0",
|
||||
"semi-static": "0.0.4",
|
||||
"sound-effect-manager": "0.0.5",
|
||||
"stanza.io": "3.2.4",
|
||||
"stanza.io": "3.6.x",
|
||||
"staydown": "1.0.3",
|
||||
"templatizer": "0.1.2",
|
||||
"underscore": "1.5.1",
|
||||
|
Loading…
Reference in New Issue
Block a user