socket timeout set to 5 seconds

parent 360185ed
Showing with 8 additions and 7 deletions
...@@ -19,7 +19,7 @@ module.exports = function roomsHook (sails) { ...@@ -19,7 +19,7 @@ module.exports = function roomsHook (sails) {
* pdb_count (number of connections to the given room from Pictogram Web) * pdb_count (number of connections to the given room from Pictogram Web)
* pcb_count (number of connections to the given room from Pictogram Communicator/Supervisor) * pcb_count (number of connections to the given room from Pictogram Communicator/Supervisor)
*/ */
getUICount: function (room) { getUICount: function (room, cb) {
// Let's count number of connections per room and per UI // Let's count number of connections per room and per UI
var counter = {'PCB': 0, 'PDB': 0}; var counter = {'PCB': 0, 'PDB': 0};
//console.log('notifyRoom (' + room + ')---->\n' + JSON.stringify(sockets) + '\n' + JSON.stringify(rooms)); //console.log('notifyRoom (' + room + ')---->\n' + JSON.stringify(sockets) + '\n' + JSON.stringify(rooms));
...@@ -34,7 +34,7 @@ module.exports = function roomsHook (sails) { ...@@ -34,7 +34,7 @@ module.exports = function roomsHook (sails) {
if (err) if (err)
sails.debug.log("Error when notifying room " + JSON.stringify(err)); sails.debug.log("Error when notifying room " + JSON.stringify(err));
else else
return ({ cb({
'room': room, 'room': room,
'pdb_count': counter['PDB'], 'pdb_count': counter['PDB'],
'pcb_count': counter['PCB'] 'pcb_count': counter['PCB']
...@@ -49,10 +49,12 @@ module.exports = function roomsHook (sails) { ...@@ -49,10 +49,12 @@ module.exports = function roomsHook (sails) {
*/ */
notifyRoom: function(room) { notifyRoom: function(room) {
// Broadcast data to room's peers // Broadcast data to room's peers
sails.hooks.events.broadcastEvent( sails.hooks.events.getUICount(room, (info) => {
room, sails.hooks.events.broadcastEvent(
sails.hooks.events.roomSubscribersChange(sails.hooks.events.getUICount(room)); room,
); sails.hooks.events.roomSubscribersChange(info)
);
});
}, },
/************************************************************************** /**************************************************************************
...@@ -189,6 +191,5 @@ module.exports = function roomsHook (sails) { ...@@ -189,6 +191,5 @@ module.exports = function roomsHook (sails) {
sails.hooks.rooms.unsubscribeFromRoom(sockets[socket.id].sup_room, socket); sails.hooks.rooms.unsubscribeFromRoom(sockets[socket.id].sup_room, socket);
} }
} }
}; };
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment