diff --git a/server.ts b/server.ts index 95ae8e0..0cdb6e4 100644 --- a/server.ts +++ b/server.ts @@ -193,16 +193,20 @@ console.log(__dirname); universalGetLatestBlockDetails('Testnet'); universalGetLatestBlockDetails('Floonet'); }); + var interval; const io = require("socket.io").listen(server); io.sockets.on("connection", socket => { + // if (interval) { + // clearInterval(interval); + // } //console.log(socket.handshake.query.network); //var network = "Testnet"; let key = process.env.REDIS_KEY + socket.handshake.query.network + 'Latest_Block_details' - setInterval(function() { + interval = setInterval(function() { Global.client.get(key, function(err, reply){ socket.emit("latestblockdetail", JSON.parse(reply) ); }); - },1000); + },10000); //socket.on("disconnect", () => console.log("Client disconnected")); }); }) diff --git a/src/app/shared/services/chart.service.ts b/src/app/shared/services/chart.service.ts index d66dc4e..dc6628d 100644 --- a/src/app/shared/services/chart.service.ts +++ b/src/app/shared/services/chart.service.ts @@ -58,6 +58,7 @@ export class ChartService { return new HttpHeaders().set('network', network); } + public getLatestblockdetails() { if(this.socket==null){ diff --git a/src/app/view/home/latestblocks/latestblocks.component.ts b/src/app/view/home/latestblocks/latestblocks.component.ts index d95beb2..a21524b 100644 --- a/src/app/view/home/latestblocks/latestblocks.component.ts +++ b/src/app/view/home/latestblocks/latestblocks.component.ts @@ -65,7 +65,7 @@ export class LatestblocksComponent implements OnInit { //console.log(this.blockdetails); if (this.lastblock != this.blockdetails.block_height) { //console.log('Create'); - this.createBlock(); + //this.createBlock(); } this.lastblock = this.blockdetails.block_height; //console.log(this.lastblock);