Skip to content

Commit

Permalink
Merge pull request #170 from matiu/feature/noMessages
Browse files Browse the repository at this point in the history
Feature/no messages
  • Loading branch information
cmgustavo committed Aug 29, 2014
2 parents 072af6b + 384ce8a commit a582fda
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/controllers/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports.init = function(io_ext) {
socket.on('subscribe', function(topic) {
logger.debug('subscribe to ' + topic);
socket.join(topic);
socket.emit('subscribed');
});

// disconnect handler
Expand Down
9 changes: 7 additions & 2 deletions plugins/mailbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ module.exports.init = function(ext_io, config) {
throw new Error('Couldn\'t get messages on sync request: ' + err);
}
logger.verbose('\tFound ' + messages.length + ' message' + (messages.length !== 1 ? 's' : ''));
for (var i = 0; i < messages.length; i++) {
broadcastMessage(messages[i], socket);

if (messages.length) {
for (var i = 0; i < messages.length; i++) {
broadcastMessage(messages[i], socket);
}
} else {
socket.emit('no messages');
}
});
});
Expand Down

0 comments on commit a582fda

Please sign in to comment.