mirror of
https://github.com/moparisthebest/kaiwa
synced 2024-11-25 18:52:20 -05:00
Got things mostly almost working
This commit is contained in:
parent
59dceeee59
commit
5ccdc6361b
@ -9,6 +9,7 @@ var uuid = require('node-uuid');
|
||||
var Contact = require('../models/contact');
|
||||
var Resource = require('../models/resource');
|
||||
var Message = require('../models/message');
|
||||
var Call = require('../models/call');
|
||||
|
||||
|
||||
var discoCapsQueue = async.queue(function (pres, cb) {
|
||||
@ -337,31 +338,37 @@ module.exports = function (client, app) {
|
||||
|
||||
client.on('jingle:incoming', function (session) {
|
||||
var contact = me.getContact(session.peer);
|
||||
me.calls.add({
|
||||
var call = new Call({
|
||||
contact: contact,
|
||||
state: 'incoming',
|
||||
jingleSession: session
|
||||
});
|
||||
contact.jingleCall = call;
|
||||
me.calls.add(call);
|
||||
});
|
||||
|
||||
client.on('jingle:outgoing', function (session) {
|
||||
var contact = me.getContact(session.peer);
|
||||
me.calls.add({
|
||||
var call = new Call({
|
||||
contact: contact,
|
||||
state: 'outgoing',
|
||||
jingleSession: session
|
||||
});
|
||||
contact.jingleCall = call;
|
||||
me.calls.add(call);
|
||||
});
|
||||
|
||||
client.on('jingle:terminated', function (session) {
|
||||
var contact = me.getContact(session.peer);
|
||||
contact.callState = '';
|
||||
contact.jingleCall = null;
|
||||
contact.onCall = false;
|
||||
});
|
||||
|
||||
client.on('jingle:accepted', function (session) {
|
||||
var contact = me.getContact(session.peer);
|
||||
contact.callState = 'activeCall';
|
||||
contact.onCall = true;
|
||||
});
|
||||
|
||||
client.on('jingle:localstream:added', function (stream) {
|
||||
@ -375,13 +382,11 @@ module.exports = function (client, app) {
|
||||
client.on('jingle:remotestream:added', function (session) {
|
||||
var contact = me.getContact(session.peer);
|
||||
contact.stream = session.stream;
|
||||
contact.trigger('change:stream');
|
||||
});
|
||||
|
||||
client.on('jingle:remotestream:removed', function (session) {
|
||||
var contact = me.getContact(session.peer);
|
||||
contact.stream = null;
|
||||
contact.trigger('change:stream');
|
||||
});
|
||||
|
||||
client.on('jingle:ringing', function (session) {
|
||||
|
@ -23,6 +23,7 @@ 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();
|
||||
@ -30,7 +31,9 @@ module.exports = BasePage.extend(chatHelpers).extend({
|
||||
events: {
|
||||
'keydown textarea': 'handleKeyDown',
|
||||
'keyup textarea': 'handleKeyUp',
|
||||
'click .call': 'handleCallClick'
|
||||
'click .call': 'handleCallClick',
|
||||
'click .end': 'handleEndClick',
|
||||
'click .mute': 'handleMuteClick'
|
||||
},
|
||||
srcBindings: {
|
||||
avatar: 'header .avatar'
|
||||
@ -198,12 +201,6 @@ module.exports = BasePage.extend(chatHelpers).extend({
|
||||
var resources = val || this.model.jingleResources;
|
||||
this.$('button.call').prop('disabled', !resources.length);
|
||||
},
|
||||
handleStream: function () {
|
||||
this.attach = attachMediaStream;
|
||||
if (!!this.model.stream) {
|
||||
attachMediaStream(this.model.stream, this.$('.remoteVideo')[0]);
|
||||
}
|
||||
},
|
||||
appendModel: function (model, preload) {
|
||||
var self = this;
|
||||
var isGrouped = model.shouldGroupWith(this.lastModel);
|
||||
@ -221,5 +218,27 @@ module.exports = BasePage.extend(chatHelpers).extend({
|
||||
this.lastModel = model;
|
||||
|
||||
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({
|
||||
condition: 'success'
|
||||
});
|
||||
return false;
|
||||
},
|
||||
handleMuteClick: function (e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user