Browse Source

Rename calls to connection and remove static-ness

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/619/head
Joas Schilling 8 years ago
parent
commit
fe04d506fa
No known key found for this signature in database GPG Key ID: 7076EA9751AACDDA
  1. 55
      js/app.js
  2. 41
      js/connection.js
  3. 3
      js/signaling.js
  4. 4
      js/views/callinfoview.js
  5. 6
      js/views/roomlistview.js
  6. 7
      js/webrtc.js
  7. 2
      templates/index-public.php
  8. 2
      templates/index.php

55
js/app.js

@ -37,6 +37,9 @@
/** @property {OCA.SpreedMe.Models.Room} activeRoom */
activeRoom: null,
/** @property {OCA.Talk.Connection} connection */
connection: null,
/** @property {OCA.Talk.Signaling.base} signaling */
signaling: null,
@ -143,16 +146,16 @@
$('#select-participants').on("select2-selecting", function(e) {
switch (e.object.type) {
case "user":
OCA.SpreedMe.Calls.createOneToOneVideoCall(e.val);
this.connection.createOneToOneVideoCall(e.val);
break;
case "group":
OCA.SpreedMe.Calls.createGroupVideoCall(e.val, "");
this.connection.createGroupVideoCall(e.val, "");
break;
case "createPublicRoom":
OCA.SpreedMe.Calls.createPublicVideoCall(OCA.SpreedMe.app._searchTerm);
this.connection.createPublicVideoCall(OCA.SpreedMe.app._searchTerm);
break;
case "createGroupRoom":
OCA.SpreedMe.Calls.createGroupVideoCall("", OCA.SpreedMe.app._searchTerm);
this.connection.createGroupVideoCall("", OCA.SpreedMe.app._searchTerm);
break;
default:
console.log("Unknown type", e.object.type);
@ -533,25 +536,16 @@
},
onStart: function() {
this.signaling = OCA.Talk.Signaling.createConnection();
this.setEmptyContentMessage(
'icon-video-off',
t('spreed', 'Waiting for camera and microphone permissions'),
t('spreed', 'Please, give your browser access to use your camera and microphone in order to use this app.')
);
this.connection = new OCA.Talk.Connection(this);
OCA.SpreedMe.initWebRTC(this);
if (!oc_current_user) {
if (!OC.getCurrentUser().uid) {
this.initGuestName();
}
},
startSpreed: function() {
console.log('Starting spreed …');
var self = this;
$(window).unload(function () {
OCA.SpreedMe.Calls.leaveAllCalls();
this.connection.leaveAllCalls();
this.signaling.disconnect();
}.bind(this));
@ -561,24 +555,17 @@
t('spreed', 'Time to call your friends')
);
OCA.SpreedMe.initCalls(this.signaling);
this._registerPageEvents();
this.initShareRoomClipboard();
var token = $('#app').attr('data-token');
if (oc_current_user) {
if (OC.getCurrentUser().uid) {
this._showRoomList();
this.signaling.setRoomCollection(this._rooms)
.then(function(data) {
$('#app-navigation').removeClass('icon-loading');
self._roomsView.render();
this._roomsView.render();
if (data.length === 0) {
$('#select-participants').select2('open');
}
});
}.bind(this));
this._showParticipantList();
} else {
@ -586,24 +573,32 @@
this.activeRoom = new OCA.SpreedMe.Models.Room({ token: token });
this.signaling.setRoom(this.activeRoom);
}
},
startSpreed: function() {
console.log('Starting spreed …');
this._registerPageEvents();
this.initShareRoomClipboard();
var token = $('#app').attr('data-token');
if (token) {
if (OCA.SpreedMe.webrtc.sessionReady) {
OCA.SpreedMe.Calls.joinRoom(token);
this.connection.joinRoom(token);
} else {
OCA.SpreedMe.webrtc.once('connectionReady', function() {
OCA.SpreedMe.Calls.joinRoom(token);
this.connection.joinRoom(token);
});
}
}
},
startLocalMedia: function(configuration) {
OCA.SpreedMe.Calls.showCamera();
this.connection.showCamera();
this.initAudioVideoSettings(configuration);
},
_onPopState: function(params) {
if (!_.isUndefined(params.token)) {
OCA.SpreedMe.Calls.joinRoom(params.token);
this.connection.joinRoom(params.token);
}
},
onDocumentClick: function(event) {

41
js/calls.js → js/connection.js

@ -4,29 +4,34 @@
(function(OCA, OC, $) {
'use strict';
OCA.SpreedMe = OCA.SpreedMe || {};
OCA.Talk = OCA.Talk || {};
var roomsChannel = Backbone.Radio.channel('rooms');
var signaling;
function initCalls(signaling_connection) {
signaling = signaling_connection;
function Connection(app) {
this.app = app;
// Todo this should not be here
var selectParticipants = $('#select-participants');
selectParticipants.keyup(function () {
selectParticipants.tooltip('hide');
selectParticipants.removeClass('error');
});
signaling.on('roomChanged', function() {
OCA.SpreedMe.Calls.leaveCurrentCall(false);
});
this.app.signaling.on('roomChanged', function() {
this.leaveCurrentCall(false);
}.bind(this));
OCA.SpreedMe.Calls.leaveAllCalls();
// Todo this blocks multi room support
this.leaveAllCalls();
}
var roomsChannel = Backbone.Radio.channel('rooms');
OCA.Talk.Connection = Connection;
OCA.Talk.Connection.prototype = {
/** @property {OCA.Talk.Application} app */
app: null,
OCA.SpreedMe.Calls = {
showCamera: function() {
$('.videoView').removeClass('hidden');
},
@ -84,7 +89,7 @@
});
},
joinRoom: function(token) {
if (signaling.currentRoomToken === token) {
if (this.app.signaling.currentRoomToken === token) {
return;
}
@ -92,7 +97,7 @@
OCA.SpreedMe.webrtc.joinRoom(token);
},
joinCall: function(token) {
if (signaling.currentCallToken === token) {
if (this.signaling.currentCallToken === token) {
return;
}
@ -115,21 +120,21 @@
roomsChannel.trigger('leaveCurrentCall');
},
leaveAllCalls: function() {
if (signaling) {
if (this.app.signaling) {
// We currently only support a single active call.
signaling.leaveCurrentCall();
signaling.leaveCurrentRoom();
this.app.signaling.leaveCurrentCall();
this.app.signaling.leaveCurrentRoom();
}
},
showRoomDeletedMessage: function(deleter) {
if (deleter) {
OCA.SpreedMe.app.setEmptyContentMessage(
this.app.setEmptyContentMessage(
'icon-video',
t('spreed', 'Looking great today! :)'),
t('spreed', 'Time to call your friends')
);
} else {
OCA.SpreedMe.app.setEmptyContentMessage(
this.app.setEmptyContentMessage(
'icon-video-off',
t('spreed', 'This call has ended')
);
@ -137,6 +142,4 @@
}
};
OCA.SpreedMe.initCalls = initCalls;
})(OCA, OC, $);

3
js/signaling.js

@ -544,7 +544,8 @@
this.pingFails++;
return;
}
OCA.SpreedMe.Calls.leaveCurrentCall(false);
// FIXME this sounds wrong…
OCA.SpreedMe.app.connection.leaveCurrentCall(false);
}.bind(this));
};

4
js/views/callinfoview.js

@ -266,11 +266,11 @@
},
joinCall: function() {
OCA.SpreedMe.Calls.joinCall(this.model.get('token'));
OCA.SpreedMe.app.connection.joinCall(this.model.get('token'));
},
leaveCall: function() {
OCA.SpreedMe.Calls.leaveCall(this.model.get('token'));
OCA.SpreedMe.app.connection.leaveCall(this.model.get('token'));
},
/**

6
js/views/roomlistview.js

@ -177,7 +177,7 @@
leaveRoom: function() {
// If user is in that room, it should leave the associated call first.
if (this.model.get('active')) {
OCA.SpreedMe.Calls.leaveCurrentCall(true);
OCA.SpreedMe.app.connection.leaveCurrentCall(true);
}
this.$el.slideUp();
@ -195,7 +195,7 @@
//If user is in that room, it should leave that room first.
if (this.model.get('active')) {
OCA.SpreedMe.Calls.leaveCurrentCall(true);
OCA.SpreedMe.app.connection.leaveCurrentCall(true);
OC.Util.History.pushState({}, OC.generateUrl('/apps/spreed'));
}
@ -209,7 +209,7 @@
joinRoom: function(e) {
e.preventDefault();
var token = this.ui.room.attr('data-token');
OCA.SpreedMe.Calls.joinRoom(token);
OCA.SpreedMe.app.connection.joinRoom(token);
OC.Util.History.pushState({
token: token

7
js/webrtc.js

@ -188,6 +188,12 @@ var spreedPeerConnectionTable = [];
var nick = OC.getCurrentUser().displayName;
app.setEmptyContentMessage(
'icon-video-off',
t('spreed', 'Waiting for camera and microphone permissions'),
t('spreed', 'Please, give your browser access to use your camera and microphone in order to use this app.')
);
webrtc = new SimpleWebRTC({
localVideoEl: 'localVideo',
remoteVideosEl: '',
@ -769,6 +775,7 @@ var spreedPeerConnectionTable = [];
OCA.SpreedMe.webrtc.sendDirectlyToAll('status', 'speaking');
$('#localVideoContainer').addClass('speaking');
});
OCA.SpreedMe.webrtc.on('stoppedSpeaking', function(){
OCA.SpreedMe.webrtc.sendDirectlyToAll('status', 'stoppedSpeaking');
$('#localVideoContainer').removeClass('speaking');

2
templates/index-public.php

@ -27,7 +27,7 @@ script(
'simplewebrtc',
'webrtc',
'signaling',
'calls',
'connection',
'app',
'init',
]

2
templates/index.php

@ -30,7 +30,7 @@ script(
'simplewebrtc',
'webrtc',
'signaling',
'calls',
'connection',
'app',
'init',
]

Loading…
Cancel
Save