From 3108961c59f8a7dfa3c3f09553ac4478ed5cee0e Mon Sep 17 00:00:00 2001 From: cubedro Date: Tue, 23 Jun 2015 23:46:29 +0300 Subject: [PATCH] added 2 way communication for latest block on external api --- lib/collection.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/collection.js b/lib/collection.js index 9f625ab..422cd12 100644 --- a/lib/collection.js +++ b/lib/collection.js @@ -15,6 +15,19 @@ var Collection = function Collection(externalAPI) return this; } +Collection.prototype.setupSockets = function() +{ + this._externalAPI.on('connection', function (spark) + { + this._externalAPI.on('latestBlock', function (data) + { + spark.emit('latestBlock', { + number: this._highestBlock + }); + }); + }); +} + Collection.prototype.add = function(data, callback) { var node = this.getNodeOrNew({ id : data.id }, data);