mirror of
https://github.com/moparisthebest/kaiwa
synced 2024-11-22 09:12:19 -05:00
Save jingle changes
This commit is contained in:
parent
2cec815821
commit
c736a7722e
@ -28,6 +28,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
config = JSON.parse(config);
|
||||
config.useStreamManagement = false;
|
||||
|
||||
_.extend(this, Backbone.Events);
|
||||
|
||||
|
@ -333,4 +333,50 @@ module.exports = function (client, app) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
client.on('jingle:incoming', function (session) {
|
||||
var contact = me.getContact(session.peer);
|
||||
contact.callState = 'incoming';
|
||||
contact.jingleCall = session;
|
||||
});
|
||||
|
||||
client.on('jingle:outgoing', function (session) {
|
||||
var contact = me.getContact(session.peer);
|
||||
contact.callState = 'outgoing';
|
||||
contact.jingleCall = session;
|
||||
});
|
||||
|
||||
client.on('jingle:terminated', function (session) {
|
||||
var contact = me.getContact(session.peer);
|
||||
contact.callState = '';
|
||||
contact.jingleCall = null;
|
||||
});
|
||||
|
||||
client.on('jingle:accepted', function (session) {
|
||||
var contact = me.getContact(session.peer);
|
||||
contact.callState = 'active';
|
||||
});
|
||||
|
||||
client.on('jingle:localstream:added', function (stream) {
|
||||
me.stream = stream;
|
||||
});
|
||||
|
||||
client.on('jingle:localstream:removed', function () {
|
||||
me.stream = null;
|
||||
});
|
||||
|
||||
client.on('jingle:remotestream:added', function (session) {
|
||||
var contact = me.getContact(session.peer);
|
||||
contact.stream = session.stream;
|
||||
});
|
||||
|
||||
client.on('jingle:remotestream:removed', function (session) {
|
||||
var contact = me.getContact(session.peer);
|
||||
contact.stream = null;
|
||||
});
|
||||
|
||||
client.on('jingle:ringing', function (session) {
|
||||
var contact = me.getContact(session.peer);
|
||||
contact.callState = 'ringing';
|
||||
});
|
||||
};
|
||||
|
@ -2,6 +2,7 @@
|
||||
"use strict";
|
||||
|
||||
var _ = require('underscore');
|
||||
var crypto = require('crypto');
|
||||
var async = require('async');
|
||||
var uuid = require('node-uuid');
|
||||
var HumanModel = require('human-model');
|
||||
@ -44,7 +45,9 @@ module.exports = HumanModel.define({
|
||||
offlineStatus: ['string', true, ''],
|
||||
topResource: 'string',
|
||||
unreadCount: ['number', true, 0],
|
||||
_forceUpdate: ['number', true, 0]
|
||||
_forceUpdate: ['number', true, 0],
|
||||
callState: 'string',
|
||||
stream: 'object'
|
||||
},
|
||||
derived: {
|
||||
displayName: {
|
||||
@ -137,7 +140,7 @@ module.exports = HumanModel.define({
|
||||
}
|
||||
},
|
||||
jingleResources: {
|
||||
cache: false,
|
||||
deps: ['_forceUpdate'],
|
||||
fn: function () {
|
||||
return this.resources.filter(function (res) {
|
||||
return res.supportsJingleMedia;
|
||||
@ -149,6 +152,17 @@ module.exports = HumanModel.define({
|
||||
resources: Resources,
|
||||
messages: Messages
|
||||
},
|
||||
call: function () {
|
||||
if (this.jingleResources) {
|
||||
var peer = this.jingleResources[0];
|
||||
this.callState = 'starting';
|
||||
app.api.jingle.startLocalMedia(null, function (err) {
|
||||
if (!err) {
|
||||
app.api.call(peer.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
setAvatar: function (id, type) {
|
||||
var self = this;
|
||||
fetchAvatar(this.jid, id, type, function (avatar) {
|
||||
@ -254,8 +268,9 @@ module.exports = HumanModel.define({
|
||||
save: function () {
|
||||
if (!this.inRoster) return;
|
||||
|
||||
var storageId = crypto.createHash('sha1').update(this.owner + '/' + this.id).digest('hex');
|
||||
var data = {
|
||||
storageId: this.storageId,
|
||||
storageId: storageId,
|
||||
owner: this.owner,
|
||||
jid: this.jid,
|
||||
name: this.name,
|
||||
|
@ -6,7 +6,6 @@ var Contacts = require('./contacts');
|
||||
var Contact = require('./contact');
|
||||
var MUCs = require('./mucs');
|
||||
var MUC = require('./muc');
|
||||
var uuid = require('node-uuid');
|
||||
var fetchAvatar = require('../helpers/fetchAvatar');
|
||||
|
||||
|
||||
@ -74,7 +73,6 @@ module.exports = HumanModel.define({
|
||||
contact = new Contact(data);
|
||||
contact.inRoster = true;
|
||||
contact.owner = this.jid.bare;
|
||||
contact.storageId = uuid.v4();
|
||||
contact.save();
|
||||
this.contacts.add(contact);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ var templates = require('../templates');
|
||||
var Message = require('../views/message');
|
||||
var MessageModel = require('../models/message');
|
||||
var chatHelpers = require('../helpers/chatHelpers');
|
||||
var attachMediaStream = require('attachmediastream');
|
||||
|
||||
|
||||
module.exports = BasePage.extend(chatHelpers).extend({
|
||||
@ -22,6 +23,8 @@ 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:stream', this.handleStream);
|
||||
|
||||
this.render();
|
||||
},
|
||||
events: {
|
||||
@ -80,7 +83,8 @@ module.exports = BasePage.extend(chatHelpers).extend({
|
||||
handlePageUnloaded: function () {
|
||||
this.scrollPageUnload();
|
||||
},
|
||||
handleCallClick: function () {
|
||||
handleCallClick: function (e) {
|
||||
e.preventDefault();
|
||||
this.model.call();
|
||||
return false;
|
||||
},
|
||||
@ -191,6 +195,11 @@ module.exports = BasePage.extend(chatHelpers).extend({
|
||||
var resources = val || this.model.jingleResources;
|
||||
this.$('button.call').prop('disabled', !resources.length);
|
||||
},
|
||||
handleStream: function () {
|
||||
if (this.model.stream) {
|
||||
attachMediaStream(this.model.stream, this.$('.remoteVideo'));
|
||||
}
|
||||
},
|
||||
appendModel: function (model, preload) {
|
||||
var self = this;
|
||||
var isGrouped = model.shouldGroupWith(this.lastModel);
|
||||
|
@ -23,9 +23,12 @@
|
||||
"templatizer": "0.1.2",
|
||||
"underscore": "1.5.1",
|
||||
"raf-component": "1.1.1",
|
||||
"stanza.io": "2.5.7",
|
||||
"stanza.io": "2.5.9",
|
||||
"notify.js": "0.0.1",
|
||||
"wildemitter": "0.0.5"
|
||||
"wildemitter": "0.0.5",
|
||||
"attachmediastream": "",
|
||||
"crypto-browserify": "1.0.3",
|
||||
"browserify": "2.25.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"precommit-hook": "0.3.6"
|
||||
|
@ -1,5 +1,5 @@
|
||||
CACHE MANIFEST
|
||||
# 0.0.1 1381790561081
|
||||
# 0.0.1 1381820535074
|
||||
|
||||
CACHE:
|
||||
/app.js
|
||||
|
Loading…
Reference in New Issue
Block a user