From 5205c49f8967be969a72c8076b545ff5ca4879aa Mon Sep 17 00:00:00 2001 From: sabash-c Date: Thu, 22 Aug 2019 18:51:19 +0530 Subject: [PATCH] reduced socket cliet call --- src/app/shared/services/chart.service.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/shared/services/chart.service.ts b/src/app/shared/services/chart.service.ts index f1e3377..d66dc4e 100644 --- a/src/app/shared/services/chart.service.ts +++ b/src/app/shared/services/chart.service.ts @@ -14,7 +14,7 @@ import * as io from "socket.io-client"; }) export class ChartService { private server = environment.domain; - private socket; + private socket=null; private socketnetwork: any; constructor(public http: HttpClient) { @@ -23,7 +23,7 @@ export class ChartService { }else{ this.socketnetwork = localStorage.getItem('network') } - this.socket = io.connect(this.server, {query: 'network='+this.socketnetwork}); + } // public createSocketConnection() { @@ -60,6 +60,10 @@ export class ChartService { public getLatestblockdetails() { + if(this.socket==null){ + this.socket = io.connect(this.server, {requestTimeout:100000000,query: 'network='+this.socketnetwork}); + this.socket.heartbeatTimeout = 200000 + } return Observable.create(observer => { this.socket.on("latestblockdetail", response => { observer.next(response);