added 2 way communication for latest block on external api

This commit is contained in:
cubedro 2015-06-23 23:46:29 +03:00
parent 18ea9f106d
commit 3108961c59

View File

@ -15,6 +15,19 @@ var Collection = function Collection(externalAPI)
return this; 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) Collection.prototype.add = function(data, callback)
{ {
var node = this.getNodeOrNew({ id : data.id }, data); var node = this.getNodeOrNew({ id : data.id }, data);