diff --git a/clientapp/app.js b/clientapp/app.js index a8f2673..0a5c00d 100644 --- a/clientapp/app.js +++ b/clientapp/app.js @@ -62,6 +62,8 @@ module.exports = { self.api = window.client = StanzaIO.createClient(config); xmppEventHandlers(self.api, self); + self.api.jingle.startLocalMedia(); + self.api.once('session:started', function () { app.state.hasConnected = true; cb(); diff --git a/clientapp/helpers/xmppEventHandlers.js b/clientapp/helpers/xmppEventHandlers.js index fe37350..b328871 100644 --- a/clientapp/helpers/xmppEventHandlers.js +++ b/clientapp/helpers/xmppEventHandlers.js @@ -355,6 +355,7 @@ module.exports = function (client, app) { state: 'incoming', jingleSession: session }); + session.accept(); contact.jingleCall = call; me.calls.add(call); }); diff --git a/clientapp/models/contact.js b/clientapp/models/contact.js index d058b95..58dc699 100644 --- a/clientapp/models/contact.js +++ b/clientapp/models/contact.js @@ -176,11 +176,7 @@ module.exports = HumanModel.define({ if (this.jingleResources.length) { var peer = this.jingleResources[0]; this.callState = 'starting'; - app.api.jingle.startLocalMedia(null, function (err) { - if (!err) { - app.api.call(peer.id); - } - }); + app.api.call(peer.id); } else { logger.error('no jingle resources for this user'); } diff --git a/clientapp/pages/chat.js b/clientapp/pages/chat.js index 0356b18..40bba31 100644 --- a/clientapp/pages/chat.js +++ b/clientapp/pages/chat.js @@ -23,9 +23,6 @@ module.exports = BasePage.extend(chatHelpers).extend({ this.listenTo(this.model.messages, 'change:edited', this.refreshModel); this.listenTo(this.model.messages, 'change:pending', this.refreshModel); - this.listenTo(this.model, 'change:onCall', this.handleCall); - this.listenTo(this.model, 'change:stream', this.handleStream); - this.render(); }, events: { @@ -226,20 +223,6 @@ module.exports = BasePage.extend(chatHelpers).extend({ this.scrollIfPinned(); }, - handleCall: function () { - if (this.model.onCall) { - /* - attachMediaStream(me.stream, this.$('video.local')[0], { - mirror: true, - muted: true - }); -*/ - } - }, - handleStream: function (model, stream) { - console.log(arguments); - attachMediaStream(stream, this.$('video.remote')[0]); - }, handleEndClick: function (e) { e.preventDefault(); this.model.jingleCall.end({ diff --git a/clientapp/views/call.js b/clientapp/views/call.js index 9e62ccd..a468535 100644 --- a/clientapp/views/call.js +++ b/clientapp/views/call.js @@ -37,12 +37,10 @@ module.exports = HumanView.extend({ handleAnswerClick: function (e) { e.preventDefault(); var self = this; - app.api.jingle.startLocalMedia(null, function () { - self.model.jingleSession.accept(); - self.model.state = 'active'; - app.navigate('/chat/' + self.model.contact.jid); - self.model.contact.onCall = true; - }); + self.model.state = 'active'; + app.navigate('/chat/' + self.model.contact.jid); + self.model.contact.onCall = true; + self.model.jingleSession.accept(); return false; }, handleIgnoreClick: function (e) { diff --git a/package.json b/package.json index eabfdf2..7b3d781 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "templatizer": "0.1.2", "underscore": "1.5.1", "raf-component": "1.1.1", - "stanza.io": "2.5.12", + "stanza.io": "2.5.14", "notify.js": "0.0.3", "wildemitter": "0.0.5", "attachmediastream": "1.0.1",