Changes updated

This commit is contained in:
root 2019-08-22 18:58:32 +05:30
parent 92efe7e8d1
commit 3db3ea2a1a
3 changed files with 8 additions and 3 deletions

View File

@ -193,16 +193,20 @@ console.log(__dirname);
universalGetLatestBlockDetails('Testnet'); universalGetLatestBlockDetails('Testnet');
universalGetLatestBlockDetails('Floonet'); universalGetLatestBlockDetails('Floonet');
}); });
var interval;
const io = require("socket.io").listen(server); const io = require("socket.io").listen(server);
io.sockets.on("connection", socket => { io.sockets.on("connection", socket => {
// if (interval) {
// clearInterval(interval);
// }
//console.log(socket.handshake.query.network); //console.log(socket.handshake.query.network);
//var network = "Testnet"; //var network = "Testnet";
let key = process.env.REDIS_KEY + socket.handshake.query.network + 'Latest_Block_details' 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){ Global.client.get(key, function(err, reply){
socket.emit("latestblockdetail", JSON.parse(reply) ); socket.emit("latestblockdetail", JSON.parse(reply) );
}); });
},1000); },10000);
//socket.on("disconnect", () => console.log("Client disconnected")); //socket.on("disconnect", () => console.log("Client disconnected"));
}); });
}) })

View File

@ -59,6 +59,7 @@ export class ChartService {
} }
public getLatestblockdetails() { public getLatestblockdetails() {
if(this.socket==null){ if(this.socket==null){
this.socket = io.connect(this.server, {requestTimeout:100000000,query: 'network='+this.socketnetwork}); this.socket = io.connect(this.server, {requestTimeout:100000000,query: 'network='+this.socketnetwork});

View File

@ -65,7 +65,7 @@ export class LatestblocksComponent implements OnInit {
//console.log(this.blockdetails); //console.log(this.blockdetails);
if (this.lastblock != this.blockdetails.block_height) { if (this.lastblock != this.blockdetails.block_height) {
//console.log('Create'); //console.log('Create');
this.createBlock(); //this.createBlock();
} }
this.lastblock = this.blockdetails.block_height; this.lastblock = this.blockdetails.block_height;
//console.log(this.lastblock); //console.log(this.lastblock);