Skip to content

Commit

Permalink
Merge pull request lynckia#39 from minervaproject/updateDevelopment
Browse files Browse the repository at this point in the history
Merge ging:master to development
  • Loading branch information
lodoyun committed Dec 27, 2016
2 parents 64946c5 + 28bad34 commit 27fdece
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 60 deletions.
24 changes: 16 additions & 8 deletions extras/basic_example/basicServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,27 @@ var deleteRoomsIfEmpty = function (theRooms, callback) {
callback(true);
return;
}
var theRoom = theRooms.pop();
N.API.getUsers(theRoom._id, function(userlist){
var theRoomId = theRooms.pop()._id;
N.API.getUsers(theRoomId, function(userlist) {
var users = JSON.parse(userlist);
if (Object.keys(users).length === 0){
N.API.deleteRoom(theRoom._id, function(){
if (theRooms.length > 0){
deleteRoomsIfEmpty(theRooms, callback);
}
N.API.deleteRoom(theRoomId, function(){
deleteRoomsIfEmpty(theRooms, callback);
});
} else {
if (theRooms.length > 0){
deleteRoomsIfEmpty(theRooms, callback);
}
}, function (error, status) {
console.log('Error getting user list for room ', theRoomId, 'reason: ', error);
switch (status) {
case 404:
deleteRoomsIfEmpty(theRooms, callback);
}
break;
case 503:
N.API.deleteRoom(theRoomId, function(){
deleteRoomsIfEmpty(theRooms, callback);
});
break;
}
});
};
Expand Down
15 changes: 9 additions & 6 deletions extras/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ MAINTAINER Lynckia
WORKDIR /opt

# Download latest version of the code and install dependencies
RUN apt-get update && apt-get install -y git && \
git clone https://github.com/ging/licode.git && \
./licode/scripts/installUbuntuDeps.sh --cleanup
RUN apt-get update && apt-get install -y git wget && \
git clone https://github.com/ging/licode.git

WORKDIR /opt/licode

# Install Licode components
RUN ./licode/scripts/installErizo.sh && \
./licode/scripts/installNuve.sh && \
./licode/scripts/installBasicExample.sh
RUN ./scripts/installUbuntuDeps.sh --cleanup && \
./scripts/installErizo.sh && \
./scripts/installNuve.sh && \
./scripts/installBasicExample.sh

COPY initDockerLicode.sh /opt/
CMD ["./initDockerLicode.sh"]

3 changes: 0 additions & 3 deletions nuve/nuveAPI/cloudHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,6 @@ exports.getUsersInRoom = function (roomId, callback) {
}
var rpcID = 'erizoController_' + room.erizoControllerId;
rpc.callRpc(rpcID, 'getUsersInRoom', [roomId], {'callback': function (users) {
if (users === 'timeout') {
users = '?';
}
callback(users);
}});

Expand Down
18 changes: 9 additions & 9 deletions nuve/nuveAPI/resource/roomResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ var doInit = function (req, callback) {
exports.represent = function (req, res) {
doInit(req, function (currentRoom) {
if (req.service === undefined) {
res.send('Client unathorized', 401);
res.status(401).send('Client unathorized');
} else if (currentRoom === undefined) {
log.info('message: representRoom - room does not exits, roomId: ' + req.params.room);
res.send('Room does not exist', 404);
res.status(404).send('Room does not exist');
} else {
log.info('message: representRoom success, roomId: ' + currentRoom._id +
', serviceId: ' + req.service._id);
Expand All @@ -42,13 +42,13 @@ exports.represent = function (req, res) {
exports.updateRoom = function (req, res) {
doInit(req, function (currentRoom) {
if (req.service === undefined) {
res.send('Client unathorized', 401);
res.status(401).send('Client unathorized');
} else if (currentRoom === undefined) {
log.info('message: updateRoom - room does not exist + roomId: ' + req.params.room);
res.send('Room does not exist', 404);
res.status(404).send('Room does not exist');
} else if (req.body.name === undefined) {
log.info('message: updateRoom - Invalid room');
res.send('Invalid room', 400);
res.status(400).send('Invalid room');
} else {
var id = '',
array = req.service.rooms,
Expand Down Expand Up @@ -94,10 +94,10 @@ exports.updateRoom = function (req, res) {
exports.patchRoom = function (req, res) {
doInit(req, function (currentRoom) {
if (req.service === undefined) {
res.send('Client unathorized', 401);
res.status(401).send('Client unathorized');
} else if (currentRoom === undefined) {
log.info('message: pachRoom - room does not exist, roomId : ' + req.params.room);
res.send('Room does not exist', 404);
res.status(404).send('Room does not exist');
} else {
var id = '',
array = req.service.rooms,
Expand Down Expand Up @@ -145,10 +145,10 @@ exports.patchRoom = function (req, res) {
exports.deleteRoom = function (req, res) {
doInit(req, function (currentRoom) {
if (req.service === undefined) {
res.send('Client unathorized', 401);
res.status(401).send('Client unathorized');
} else if (currentRoom === undefined) {
log.info('message: deleteRoom - room does not exist, roomId: ' + req.params.room);
res.send('Room does not exist', 404);
res.status(404).send('Room does not exist');
} else {
var id = '',
array = req.service.rooms,
Expand Down
6 changes: 3 additions & 3 deletions nuve/nuveAPI/resource/roomsResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ exports.createRoom = function (req, res) {
var currentService = req.service;

if (currentService === undefined) {
res.send('Service not found', 404);
res.status(404).send('Service not found');
return;
}
if (req.body.name === undefined) {
log.info('message: createRoom - invalid room name');
res.send('Invalid room', 400);
res.status(400).send('Invalid room');
return;
}

Expand Down Expand Up @@ -67,7 +67,7 @@ exports.createRoom = function (req, res) {
exports.represent = function (req, res) {
var currentService = req.service;
if (currentService === undefined) {
res.send('Service not found', 404);
res.status(404).send('Service not found');
return;
}
log.info('message: representRooms, serviceId: ' + currentService._id);
Expand Down
8 changes: 4 additions & 4 deletions nuve/nuveAPI/resource/serviceResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ exports.represent = function (req, res) {
if (serv === 'error') {
log.info('message: represent service - not authorized, serviceId: ' +
req.params.service);
res.send('Service not authorized for this action', 401);
res.status(401).send('Service not authorized for this action');
return;
}
if (serv === undefined) {
res.send('Service not found', 404);
res.status(404).send('Service not found');
return;
}
log.info('Representing service ', serv._id);
Expand All @@ -51,11 +51,11 @@ exports.deleteService = function (req, res) {
doInit(req, function (serv) {
if (serv === 'error') {
log.info('message: deleteService - not authorized, serviceId: ' + req.params.service);
res.send('Service not authorized for this action', 401);
res.status(401).send('Service not authorized for this action');
return;
}
if (serv === undefined) {
res.send('Service not found', 404);
res.status(404).send('Service not found');
return;
}
var id = '';
Expand Down
4 changes: 2 additions & 2 deletions nuve/nuveAPI/resource/servicesResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var doInit = function (req) {
exports.create = function (req, res) {
if (!doInit(req)) {
log.info('message: createService - unauthorized, serviceId: ' + req.service._id);
res.send('Service not authorized for this action', 401);
res.status(401).send('Service not authorized for this action');
return;
}

Expand All @@ -39,7 +39,7 @@ exports.create = function (req, res) {
exports.represent = function (req, res) {
if (!doInit(req)) {
log.info('message: representService - not authorised, serviceId: ' + req.service._id);
res.send('Service not authorized for this action', 401);
res.status(401).send('Service not authorized for this action');
return;
}

Expand Down
4 changes: 2 additions & 2 deletions nuve/nuveAPI/resource/tokensResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ exports.create = function (req, res) {
doInit(req, function (currentService, currentRoom) {
if (currentService === undefined) {
log.warn('message: createToken - service not found');
res.send('Service not found', 404);
res.status(404).send('Service not found');
return;
} else if (currentRoom === undefined) {
log.warn('message: createToken - room not found, roomId: ' + req.params.room);
res.send('Room does not exist', 404);
res.status(404).send('Room does not exist');
return;
}

Expand Down
14 changes: 7 additions & 7 deletions nuve/nuveAPI/resource/userResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ exports.getUser = function (req, res) {
doInit(req, function (currentService, currentRoom) {

if (currentService === undefined) {
res.send('Service not found', 404);
res.status(404).send('Service not found');
return;
} else if (currentRoom === undefined) {
log.info('message: getUser - room not found, roomId: ' + req.params.room);
res.send('Room does not exist', 404);
res.status(404).send('Room does not exist');
return;
}

Expand All @@ -41,7 +41,7 @@ exports.getUser = function (req, res) {

cloudHandler.getUsersInRoom(currentRoom._id, function (users) {
if (users === 'error') {
res.send('CloudHandler does not respond', 401);
res.status(401).send('CloudHandler does not respond');
return;
}
for (var index in users){
Expand All @@ -54,7 +54,7 @@ exports.getUser = function (req, res) {

}
log.error('message: getUser user not found, userId: ' + req.params.user);
res.send('User does not exist', 404);
res.status(404).send('User does not exist');
return;


Expand All @@ -71,19 +71,19 @@ exports.deleteUser = function (req, res) {
doInit(req, function (currentService, currentRoom) {

if (currentService === undefined) {
res.send('Service not found', 404);
res.status(404).send('Service not found');
return;
} else if (currentRoom === undefined) {
log.info('message: deleteUser - room not found, roomId: ' + req.params.room);
res.send('Room does not exist', 404);
res.status(404).send('Room does not exist');
return;
}

var user = req.params.user;

cloudHandler.deleteUser (user, currentRoom._id, function(result){
if(result === 'User does not exist'){
res.send(result, 404);
res.status(404).send(result);
}
else {
res.send(result);
Expand Down
8 changes: 4 additions & 4 deletions nuve/nuveAPI/resource/usersResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ exports.getList = function (req, res) {
doInit(req, function (currentService, currentRoom) {

if (currentService === undefined) {
res.send('Service not found', 404);
res.status(404).send('Service not found');
return;
} else if (currentRoom === undefined) {
log.info('message: getUserList - room not found, roomId: ' + req.params.room);
res.send('Room does not exist', 404);
res.status(404).send('Room does not exist');
return;
}

log.info('message: getUsersList success, roomId: ' + currentRoom._id +
', serviceId: ' + currentService._id);
cloudHandler.getUsersInRoom(currentRoom._id, function (users) {
if (users === 'error') {
res.send('CloudHandler does not respond', 401);
if (users === 'timeout') {
res.status(503).send('Erizo Controller managing this room does not respond');
return;
}
res.send(users);
Expand Down
4 changes: 2 additions & 2 deletions nuve/nuveAPI/test/resource/usersResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ describe('Users Resource', function() {
it('should fail if CloudHandler does not respond', function(done) {
serviceRegistryMock.getRoomForService.callsArgWith(2, kArbitraryRoom);
setServiceStub.returns(kArbitraryService);
cloudHandlerMock.getUsersInRoom.callsArgWith(1, 'error');
cloudHandlerMock.getUsersInRoom.callsArgWith(1, 'timeout');
request(app)
.get('/rooms/1/users')
.expect(401, 'CloudHandler does not respond')
.expect(503, 'Erizo Controller managing this room does not respond')
.end(function(err) {
if (err) throw err;
done();
Expand Down
11 changes: 1 addition & 10 deletions nuve/nuveClient/src/N.API.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,9 @@ N.API = (function (N) {
case 205:
callback(req.responseText);
break;
case 400:
if (callbackError !== undefined) callbackError('400 Bad Request');
break;
case 401:
if (callbackError !== undefined) callbackError('401 Unauthorized');
break;
case 403:
if (callbackError !== undefined) callbackError('403 Forbidden');
break;
default:
if (callbackError !== undefined) {
callbackError(req.status + ' Error' + req.responseText);
callbackError(req.status + ' Error' + req.responseText, req.status);
}
}
}
Expand Down

0 comments on commit 27fdece

Please sign in to comment.