mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 06:02:36 +03:00
OP-2481 Fix ws subscription issue
This commit is contained in:
@@ -254,14 +254,14 @@ class OrionAggregatorWS {
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.ws?.close(4000);
|
||||
this.ws?.close();
|
||||
delete this.ws;
|
||||
}
|
||||
|
||||
init(isReconnect = false) {
|
||||
this.ws = new WebSocket(this.wsUrl);
|
||||
this.ws.onclose = (e) => {
|
||||
if (e.code !== 4000) this.init(true);
|
||||
if (this.ws) this.init(true);
|
||||
};
|
||||
this.ws.onopen = () => {
|
||||
// Re-subscribe to all subscriptions
|
||||
|
||||
@@ -108,7 +108,7 @@ export default class PriceFeedSubscription<T extends SubscriptionType = Subscrip
|
||||
|
||||
this.ws.onclose = (e) => {
|
||||
if (this.heartbeatInterval) clearInterval(this.heartbeatInterval);
|
||||
if (e.code !== 4000) this.init();
|
||||
if (this.ws) this.init();
|
||||
};
|
||||
|
||||
this.heartbeatInterval = setInterval(() => {
|
||||
@@ -117,6 +117,7 @@ export default class PriceFeedSubscription<T extends SubscriptionType = Subscrip
|
||||
}
|
||||
|
||||
kill() {
|
||||
this.ws?.close(4000);
|
||||
this.ws?.close();
|
||||
delete this.ws;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user