@evergis/api
Advanced tools
Comparing version 0.1.21 to 0.1.22
@@ -9,2 +9,3 @@ import { NotificationService } from '../__generated__/NotificationService'; | ||
private wsUrl?; | ||
private reconnectCount; | ||
constructor(info: ServiceInfoDc, http: IHttpClient); | ||
@@ -17,3 +18,2 @@ on<Data, Result>(tag: string, handler: NotificationHandler<Data, Result>): void; | ||
private connect; | ||
private onWsConnected; | ||
private onWsClosed; | ||
@@ -20,0 +20,0 @@ private onWsMessage; |
@@ -6,8 +6,10 @@ import { NotificationService } from '../__generated__/NotificationService'; | ||
super(info, http); | ||
this.onWsConnected = () => { | ||
console.log('WebSocket connection established.'); | ||
}; | ||
this.onWsClosed = () => { | ||
console.log('WebSocket connection closed.'); | ||
this.connect(); | ||
if (this.reconnectCount < 5) { | ||
this.connect(); | ||
this.reconnectCount += 1; | ||
} | ||
else { | ||
console.log("Unable to connect via websocket after 5 attempts"); | ||
} | ||
}; | ||
@@ -28,2 +30,3 @@ this.onWsMessage = (event) => { | ||
this.emitter = new EventEmitter(); | ||
this.reconnectCount = 0; | ||
} | ||
@@ -59,3 +62,2 @@ on(tag, handler) { | ||
this.ws = new WebSocket(this.wsUrl); | ||
this.ws.onopen = this.onWsConnected; | ||
this.ws.onclose = this.onWsClosed; | ||
@@ -62,0 +64,0 @@ this.ws.onmessage = this.onWsMessage; |
{ | ||
"name": "@evergis/api", | ||
"version": "0.1.21", | ||
"version": "0.1.22", | ||
"license": "ISC", | ||
@@ -5,0 +5,0 @@ "author": "everpoint", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
227848
4935