Skip to content

Commit

Permalink
Fix lelylan#17 - Add function for all events
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeG committed Apr 17, 2017
1 parent 0de8de5 commit c5d028d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var Event = require('../app/models/jobs/event')
// find the valid tokens associated to property-udpated events
exports.execute = function(io) {
Event.db.db.executeDbCommand({"convertToCapped": "events", size: 10000000, max:1000})
Event.find({ websocket_processed: false, event: 'property-update' })
Event.find({ websocket_processed: false })
.tailable().stream().on('data', function(collection) { findTokens(collection, io) });
}

Expand All @@ -28,7 +28,10 @@ var findTokens = function(event, io) {

// avoid the emitting for tokens that are not used from a web client
if (io.sockets.manager.rooms['/' + room]) {
io.sockets.in(room).emit('update', { data: event.data, token: event.token });
io.sockets.in(room).emit(event.event, { data: event.data, token: event.token });
if (event.event === 'property-update') {
io.sockets.in(room).emit('update', { data: event.data, token: event.token });
}
}
});

Expand Down

0 comments on commit c5d028d

Please sign in to comment.