Skip to content

Commit

Permalink
Implemented stat subscription renewal and filtered stats to clients (l…
Browse files Browse the repository at this point in the history
  • Loading branch information
lodoyun authored Jul 24, 2017
1 parent 79f5d26 commit c0754cb
Show file tree
Hide file tree
Showing 6 changed files with 486 additions and 425 deletions.
22 changes: 10 additions & 12 deletions ackuaria.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ N.API.getRooms(function(roomList) {
streams: [],
users: [],
failed: []
};
};
}
}
})
Expand Down Expand Up @@ -84,22 +84,20 @@ amqper.connect(function() {
}
}
}
for (var s in API.sockets) {
API.sockets[s].emit('agentsEvent', {
agents: API.agents,
streams: streams
});
}

API.sockets.forEach((currentSocket, currentSocketId) => {
currentSocket.emit('agentsEvent', {
agents: API.agents,
streams: streams
});
});
});
}
getErizoAgents();
setInterval(getErizoAgents, 5000);
});

io.on('connection', function(socket) {
API.sockets.push(socket);
});
io.on('connection', API.addNewConnection);


app.use('/ackuaria', ackuaria_router);

Expand Down Expand Up @@ -147,4 +145,4 @@ ackuaria_router.post('/delete/:roomID', function(req, res) {

ackuaria_router.get('/agents', ackuariaController.loadAgents)

ackuaria_router.get('/agent', ackuariaController.loadAgent)
ackuaria_router.get('/agent', ackuariaController.loadAgent)
10 changes: 8 additions & 2 deletions ackuaria_config.js.template
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ config.rabbit.port = 5672; //default value: 5672
config.logger = {};
config.logger.config_file = './log4js_configuration.json'; //default value: "../log4js_configuration.json"


/*********************************************************
DB CONFIGURATION.
If not used, only real-time data will be provided
Expand All @@ -34,8 +33,15 @@ config.nuve.host = 'http://localhost:3000/'; // default value: 'http://localhost
config.nuve.superserviceID = ''; // default value: ''
config.nuve.superserviceKey = ''; // default value: ''

/*********************************************************
LICODE STATS CONFIGURATION
**********************************************************/
config.stats = {};
config.stats.subscriptionDuration = 60;
config.stats.subscriptionInterval = 1;


/***** END *****/
// Following lines are always needed.
var module = module || {};
module.exports = config;
module.exports = config;
15 changes: 8 additions & 7 deletions common/amqper.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
var sys = require('util');
var amqp = require('amqp');
var logger = require('./logger').logger;

var config = require('./../ackuaria_config');
// Logger
var log = logger.getLogger("AMQPER");

// Configuration default values
GLOBAL.config.rabbit = GLOBAL.config.rabbit || {};
GLOBAL.config.rabbit.host = GLOBAL.config.rabbit.host || 'localhost';
GLOBAL.config.rabbit.port = GLOBAL.config.rabbit.port || 5672;
GLOBAL.config = config || {};
GLOBAL.config.rabbit = config.rabbit || {};
GLOBAL.config.rabbit.host = config.rabbit.host || 'localhost';
GLOBAL.config.rabbit.port = config.rabbit.port || 5672;

var TIMEOUT = 5000;

Expand Down Expand Up @@ -123,7 +124,7 @@ exports.bind_broadcast = function(id, callback) {

q.bind('broadcastExchange', id);
q.subscribe(function (m){callback(m)});

} catch (err) {
log.error("Error in exchange ", exchange.name, " - error - ", err);
}
Expand All @@ -136,7 +137,7 @@ exports.bind_broadcast = function(id, callback) {
*/
exports.broadcast = function(topic, message, callback) {
var body = {message: message};

if (callback) {
corrID ++;
map[corrID] = {};
Expand Down Expand Up @@ -168,4 +169,4 @@ var callbackError = function(corrID) {
map[corrID].fn[i]('timeout');
}
delete map[corrID];
}
}
Loading

0 comments on commit c0754cb

Please sign in to comment.