Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple room session support #748

Merged
merged 10 commits into from
Mar 28, 2018
25 changes: 22 additions & 3 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,25 @@
],
],
'ocs' => [
/**
* Signaling
*/
[
'name' => 'Signaling#signaling',
'url' => '/api/{apiVersion}/signaling',
'url' => '/api/{apiVersion}/signaling/{token}',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v1',
'token' => '^[a-z0-9]{4,30}$',
],
],
[
'name' => 'Signaling#pullMessages',
'url' => '/api/{apiVersion}/signaling',
'url' => '/api/{apiVersion}/signaling/{token}',
'verb' => 'GET',
'requirements' => [
'apiVersion' => 'v1',
'token' => '^[a-z0-9]{4,30}$',
],
],
[
Expand All @@ -62,6 +67,10 @@
'apiVersion' => 'v1',
],
],

/**
* Call
*/
[
'name' => 'Call#getPeersForCall',
'url' => '/api/{apiVersion}/call/{token}',
Expand Down Expand Up @@ -99,6 +108,9 @@
],
],

/**
* Chat
*/
[
'name' => 'Chat#receiveMessages',
'url' => '/api/{apiVersion}/chat/{token}',
Expand All @@ -118,6 +130,9 @@
],
],

/**
* Room
*/
[
'name' => 'Room#getRooms',
'url' => '/api/{apiVersion}/room',
Expand Down Expand Up @@ -239,7 +254,7 @@
],
],
[
'name' => 'Room#exitRoom',
'name' => 'Room#leaveRoom',
'url' => '/api/{apiVersion}/room/{token}/participants/active',
'verb' => 'DELETE',
'requirements' => [
Expand All @@ -265,6 +280,10 @@
'token' => '^[a-z0-9]{4,30}$',
],
],

/**
* Guest
*/
[
'name' => 'Guest#setDisplayName',
'url' => '/api/{apiVersion}/guest/{token}/name',
Expand Down
2 changes: 1 addition & 1 deletion css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ video {
#app-sidebar .participantWithList {
overflow-y: auto;
/* Add room for the popovermenu on last user */
padding-bottom: 50px;
padding-bottom: 64px;
}

/**
Expand Down
17 changes: 17 additions & 0 deletions docs/api-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
- [Chat](#chat)
* [Receive chat messages of a room](#receive-chat-messages-of-a-room)
* [Sending a new chat message](#sending-a-new-chat-message)
- [Guests](#guests)
* [Set display name](#set-display-name)
- [Signaling](#signaling)


Expand All @@ -46,6 +48,21 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1`
* `5` user following a public link


## Capabilities

### 3.0 (Initial Talk release)
* `audio` - audio is supported
* `video` - video + screensharing is supported
* `chat` - simple text chat is supported

### 3.1
* `guest-signaling` - Guests can do signaling via api endpoints
* `empty-group-room` - Group rooms can be created without inviting a Nextcloud user group by default

### 3.2
* `guest-display-names` - Display names of guests are stored in the database, can be set via API (not WebRTC only) and are used on returned comments/participants/etc.
* `multi-room-users` - Users can be in multiple rooms at the same time now, therefor signaling now also requires the room/call token on the URL


## Room management

Expand Down
4 changes: 2 additions & 2 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@
this.token = $('#app').attr('data-token');

$(window).unload(function () {
this.connection.leaveAllCalls();
this.connection.leaveCurrentRoom(false);
this.signaling.disconnect();
}.bind(this));

Expand Down Expand Up @@ -638,7 +638,7 @@
}
},
startLocalMedia: function(configuration) {
this.connection.showCamera();
$('.videoView').removeClass('hidden');
this.initAudioVideoSettings(configuration);
this.restoreEmptyContent();
},
Expand Down
36 changes: 9 additions & 27 deletions js/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,15 @@
});

this.app.signaling.on('roomChanged', function() {
this.leaveCurrentCall(false);
this.leaveCurrentRoom(false);
}.bind(this));

// Todo this blocks multi room support
this.leaveAllCalls();
}

OCA.Talk.Connection = Connection;
OCA.Talk.Connection.prototype = {
/** @property {OCA.Talk.Application} app */
app: null,

showCamera: function() {
$('.videoView').removeClass('hidden');
},
_createCallSuccessHandle: function(ocsResponse) {
var token = ocsResponse.ocs.data.token;
OC.Util.History.pushState({
Expand Down Expand Up @@ -97,42 +91,30 @@
this.app.signaling.joinRoom(token);
this.app.syncAndSetActiveRoom(token);
},
leaveCurrentRoom: function(deleter) {
this.app.signaling.leaveCurrentRoom();
OC.Util.History.pushState({}, OC.generateUrl('/apps/spreed'));
$('#app-content').removeClass('incall');
this.showRoomDeletedMessage(deleter);
roomsChannel.trigger('leaveCurrentCall');
},
joinCall: function(token) {
if (this.app.signaling.currentCallToken === token) {
return;
}

this.app.signaling.leaveCurrentCall();
this.app.signaling.joinCall(token);
this.app.signaling.syncRooms();

this.app.setupWebRTC();

$('#emptycontent').hide();
},
leaveCall: function(token) {
if (this.app.signaling.currentCallToken !== token) {
return;
}

leaveCurrentCall: function() {
this.app.signaling.leaveCurrentCall();
this.app.signaling.syncRooms();
$('#app-content').removeClass('incall');
},
leaveCurrentCall: function(deleter) {
this.app.signaling.leaveCall();
OC.Util.History.pushState({}, OC.generateUrl('/apps/spreed'));
$('#app-content').removeClass('incall');
this.showRoomDeletedMessage(deleter);
roomsChannel.trigger('leaveCurrentCall');
},
leaveAllCalls: function() {
if (this.app.signaling) {
// We currently only support a single active call.
this.app.signaling.leaveCurrentCall();
this.app.signaling.leaveCurrentRoom();
}
},
showRoomDeletedMessage: function(deleter) {
if (deleter) {
this.app.setEmptyContentMessage(
Expand Down
2 changes: 1 addition & 1 deletion js/models/roomcollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
var RoomCollection = Backbone.Collection.extend({
model: OCA.SpreedMe.Models.Room,
comparator: function(model) {
return -(model.get('lastPing'));
return [model.get('active') ? -1 : 0, -(model.get('lastPing'))];
},
url: OC.linkToOCS('apps/spreed/api/v1', 2) + 'room',
/**
Expand Down
45 changes: 3 additions & 42 deletions js/signaling.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@
}
};

OCA.Talk.Signaling.Base.prototype.leaveAllCalls = function() {
// Override if necessary.
};

OCA.Talk.Signaling.Base.prototype.setRoomCollection = function(rooms) {
this.roomCollection = rooms;
return this.syncRooms();
Expand Down Expand Up @@ -302,10 +298,6 @@

OCA.Talk.Signaling.Internal.prototype.disconnect = function() {
this.spreedArrayConnection = [];
if (this.source) {
this.source.close();
this.source = null;
}
if (this.sendInterval) {
window.clearInterval(this.sendInterval);
this.sendInterval = null;
Expand Down Expand Up @@ -349,7 +341,7 @@
OCA.Talk.Signaling.Internal.prototype._sendMessages = function(messages) {
var defer = $.Deferred();
$.ajax({
url: OC.linkToOCS('apps/spreed/api/v1', 2) + 'signaling',
url: OC.linkToOCS('apps/spreed/api/v1/signaling', 2) + this.currentRoomToken,
type: 'POST',
data: {messages: JSON.stringify(messages)},
beforeSend: function (request) {
Expand Down Expand Up @@ -378,7 +370,6 @@

if (token === this.currentRoomToken) {
this._stopPingCall();
this._closeEventSource();
}
};

Expand Down Expand Up @@ -414,24 +405,6 @@
}.bind(this), 10000);
};

/**
* @private
*/
OCA.Talk.Signaling.Internal.prototype._getCallPeers = function(token) {
var defer = $.Deferred();
$.ajax({
beforeSend: function (request) {
request.setRequestHeader('Accept', 'application/json');
},
url: OC.linkToOCS('apps/spreed/api/v1/call', 2) + token,
success: function (result) {
var peers = result.ocs.data;
defer.resolve(peers);
}
});
return defer;
};

/**
* @private
*/
Expand All @@ -444,7 +417,7 @@
// Connect to the messages endpoint and pull for new messages
this.pullMessagesRequest =
$.ajax({
url: OC.linkToOCS('apps/spreed/api/v1', 2) + 'signaling',
url: OC.linkToOCS('apps/spreed/api/v1/signaling', 2) + this.currentRoomToken,
type: 'GET',
dataType: 'json',
beforeSend: function (request) {
Expand Down Expand Up @@ -482,16 +455,6 @@
});
};

/**
* @private
*/
OCA.Talk.Signaling.Internal.prototype._closeEventSource = function() {
if (this.source) {
this.source.close();
this.source = null;
}
};

/**
* @private
*/
Expand Down Expand Up @@ -555,9 +518,7 @@
return;
}

// FIXME This was trying to call connection.leaveCurrentCall(false);
// FIXME UI is also not updated. But at least it stops pinging the room.
this.leaveCurrentRoom();
OCA.SpreedMe.app.connection.leaveCurrentRoom(false);
}.bind(this));
};

Expand Down
2 changes: 1 addition & 1 deletion js/views/callinfoview.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
},

leaveCall: function() {
OCA.SpreedMe.app.connection.leaveCall(this.model.get('token'));
OCA.SpreedMe.app.connection.leaveCurrentCall();
},

/**
Expand Down
12 changes: 6 additions & 6 deletions js/views/roomlistview.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
'<div class="app-navigation-entry-menu">'+
'<ul class="app-navigation-entry-menu-list">'+
'<li>'+
'<button class="leave-room-button">'+
'<button class="remove-room-button">'+
'<span class="{{#if isDeletable}}icon-close{{else}}icon-delete{{/if}}"></span>'+
'<span>'+t('spreed', 'Leave room')+'</span>'+
'<span>'+t('spreed', 'Remove room from list')+'</span>'+
'</button>'+
'</li>'+
'{{#if isDeletable}}'+
Expand Down Expand Up @@ -99,7 +99,7 @@
templateContext: function() {
return {
isDeletable: (this.model.get('participantType') === 1 || this.model.get('participantType') === 2) &&
(Object.keys(this.model.get('participants')).length > 2 || this.model.get('numGuests') > 0)
(Object.keys(this.model.get('participants')).length > 1 || this.model.get('numGuests') > 0)
};
},
onRender: function() {
Expand Down Expand Up @@ -128,7 +128,7 @@
},
events: {
'click .app-navigation-entry-utils-menu-button button': 'toggleMenu',
'click @ui.menu .leave-room-button': 'leaveRoom',
'click @ui.menu .remove-room-button': 'removeRoom',
'click @ui.menu .delete-room-button': 'deleteRoom',
'click @ui.room': 'joinRoom'
},
Expand Down Expand Up @@ -172,7 +172,7 @@
});
}
},
leaveRoom: function() {
removeRoom: function() {
this.cleanupIfActiveRoom();
this.$el.slideUp();

Expand Down Expand Up @@ -201,7 +201,7 @@
}

OCA.SpreedMe.app._chatView.$el.detach();
OCA.SpreedMe.app.connection.leaveCurrentCall(true);
OCA.SpreedMe.app.connection.leaveCurrentRoom(true);
OC.Util.History.pushState({}, OC.generateUrl('/apps/spreed'));
},
joinRoom: function(e) {
Expand Down
4 changes: 2 additions & 2 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ protected function registerInternalSignalingHooks(EventDispatcherInterface $disp
$messages->addMessageForAllParticipants($room, 'refresh-participant-list');
};

$dispatcher->addListener(Room::class . '::postUserEnterRoom', $listener);
$dispatcher->addListener(Room::class . '::postGuestEnterRoom', $listener);
$dispatcher->addListener(Room::class . '::postJoinRoom', $listener);
$dispatcher->addListener(Room::class . '::postJoinRoomGuest', $listener);
$dispatcher->addListener(Room::class . '::postRemoveUser', $listener);
$dispatcher->addListener(Room::class . '::postRemoveBySession', $listener);
$dispatcher->addListener(Room::class . '::postUserDisconnectRoom', $listener);
Expand Down
2 changes: 2 additions & 0 deletions lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public function getCapabilities() {
'chat',
'guest-signaling',
'empty-group-room',
'guest-display-names',
'multi-room-users',
],
],
];
Expand Down
Loading