mirror of
https://github.com/moparisthebest/kaiwa
synced 2024-11-22 09:12:19 -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 Contact = require('../models/contact');
|
||||||
var Resource = require('../models/resource');
|
var Resource = require('../models/resource');
|
||||||
var Message = require('../models/message');
|
var Message = require('../models/message');
|
||||||
|
var Call = require('../models/call');
|
||||||
|
|
||||||
|
|
||||||
var discoCapsQueue = async.queue(function (pres, cb) {
|
var discoCapsQueue = async.queue(function (pres, cb) {
|
||||||
@ -337,31 +338,37 @@ module.exports = function (client, app) {
|
|||||||
|
|
||||||
client.on('jingle:incoming', function (session) {
|
client.on('jingle:incoming', function (session) {
|
||||||
var contact = me.getContact(session.peer);
|
var contact = me.getContact(session.peer);
|
||||||
me.calls.add({
|
var call = new Call({
|
||||||
contact: contact,
|
contact: contact,
|
||||||
state: 'incoming',
|
state: 'incoming',
|
||||||
jingleSession: session
|
jingleSession: session
|
||||||
});
|
});
|
||||||
|
contact.jingleCall = call;
|
||||||
|
me.calls.add(call);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('jingle:outgoing', function (session) {
|
client.on('jingle:outgoing', function (session) {
|
||||||
var contact = me.getContact(session.peer);
|
var contact = me.getContact(session.peer);
|
||||||
me.calls.add({
|
var call = new Call({
|
||||||
contact: contact,
|
contact: contact,
|
||||||
state: 'outgoing',
|
state: 'outgoing',
|
||||||
jingleSession: session
|
jingleSession: session
|
||||||
});
|
});
|
||||||
|
contact.jingleCall = call;
|
||||||
|
me.calls.add(call);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('jingle:terminated', function (session) {
|
client.on('jingle:terminated', function (session) {
|
||||||
var contact = me.getContact(session.peer);
|
var contact = me.getContact(session.peer);
|
||||||
contact.callState = '';
|
contact.callState = '';
|
||||||
contact.jingleCall = null;
|
contact.jingleCall = null;
|
||||||
|
contact.onCall = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
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';
|
||||||
|
contact.onCall = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('jingle:localstream:added', function (stream) {
|
client.on('jingle:localstream:added', function (stream) {
|
||||||
@ -375,13 +382,11 @@ module.exports = function (client, app) {
|
|||||||
client.on('jingle:remotestream:added', function (session) {
|
client.on('jingle:remotestream:added', function (session) {
|
||||||
var contact = me.getContact(session.peer);
|
var contact = me.getContact(session.peer);
|
||||||
contact.stream = session.stream;
|
contact.stream = session.stream;
|
||||||
contact.trigger('change:stream');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('jingle:remotestream:removed', function (session) {
|
client.on('jingle:remotestream:removed', function (session) {
|
||||||
var contact = me.getContact(session.peer);
|
var contact = me.getContact(session.peer);
|
||||||
contact.stream = null;
|
contact.stream = null;
|
||||||
contact.trigger('change:stream');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('jingle:ringing', function (session) {
|
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:edited', this.refreshModel);
|
||||||
this.listenTo(this.model.messages, 'change:pending', 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.listenTo(this.model, 'change:stream', this.handleStream);
|
||||||
|
|
||||||
this.render();
|
this.render();
|
||||||
@ -30,7 +31,9 @@ module.exports = BasePage.extend(chatHelpers).extend({
|
|||||||
events: {
|
events: {
|
||||||
'keydown textarea': 'handleKeyDown',
|
'keydown textarea': 'handleKeyDown',
|
||||||
'keyup textarea': 'handleKeyUp',
|
'keyup textarea': 'handleKeyUp',
|
||||||
'click .call': 'handleCallClick'
|
'click .call': 'handleCallClick',
|
||||||
|
'click .end': 'handleEndClick',
|
||||||
|
'click .mute': 'handleMuteClick'
|
||||||
},
|
},
|
||||||
srcBindings: {
|
srcBindings: {
|
||||||
avatar: 'header .avatar'
|
avatar: 'header .avatar'
|
||||||
@ -198,12 +201,6 @@ module.exports = BasePage.extend(chatHelpers).extend({
|
|||||||
var resources = val || this.model.jingleResources;
|
var resources = val || this.model.jingleResources;
|
||||||
this.$('button.call').prop('disabled', !resources.length);
|
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) {
|
appendModel: function (model, preload) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var isGrouped = model.shouldGroupWith(this.lastModel);
|
var isGrouped = model.shouldGroupWith(this.lastModel);
|
||||||
@ -221,5 +218,27 @@ module.exports = BasePage.extend(chatHelpers).extend({
|
|||||||
this.lastModel = model;
|
this.lastModel = model;
|
||||||
|
|
||||||
this.scrollIfPinned();
|
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