diff --git a/plugins/mailbox.js b/plugins/mailbox.js index a9eaf9f..5d6cab7 100644 --- a/plugins/mailbox.js +++ b/plugins/mailbox.js @@ -9,45 +9,6 @@ module.exports.init = function(ext_io, config) { io = ext_io; io.sockets.on('connection', function(socket) { // when it requests sync, send him all pending messages - socket.on('sync', function(ts) { - logger.debug('Sync requested by ' + socket.id); - logger.debug(' from timestamp ' + ts); - var rooms = socket.rooms; - if (rooms.length !== 2) { - socket.emit('insight-error', 'Must subscribe with public key before syncing'); - return; - } - var to = rooms[1]; - var upper_ts = Math.round(microtime.now()); - logger.debug(' to timestamp ' + upper_ts); - mdb.getMessages(to, ts, upper_ts, function(err, messages) { - if (err) { - throw new Error('Couldn\'t get messages on sync request: ' + err); - } - logger.debug('\tFound ' + messages.length + ' message' + (messages.length !== 1 ? 's' : '')); - for (var i = 0; i < messages.length; i++) { - broadcastMessage(messages[i], socket); - } - }); - }); - - // when it sends a message, add it to db - socket.on('message', function(m) { - logger.debug('Message sent from ' + m.pubkey + ' to ' + m.to); - mdb.addMessage(m, function(err) { - if (err) { - throw new Error('Couldn\'t add message to database: ' + err); - } - }); - }); - - - // disconnect handler - socket.on('disconnect', function() { - logger.debug('disconnected ' + socket.id); - }); - - mdb.on('message', broadcastMessage); // when it requests sync, send him all pending messages socket.on('sync', function(ts) { logger.debug('Sync requested by ' + socket.id); @@ -81,7 +42,6 @@ module.exports.init = function(ext_io, config) { }); }); - // disconnect handler socket.on('disconnect', function() { logger.debug('disconnected ' + socket.id);