From e2ab8f13e44e404f534c686b8794bea4b0d9228f Mon Sep 17 00:00:00 2001 From: akaster99 Date: Thu, 14 Sep 2023 11:59:27 +0900 Subject: [PATCH] fix: delete Timeout --- src/constants.ts | 1 - src/handlers/handler.ts | 14 +++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 3088caa..9b96674 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -27,5 +27,4 @@ export const Path = { } export const SECOND = 1000; -export const HANDLER_TIMEOUT = 30 * SECOND; export const HANDLER_HEARBEAT_INTERVAL = 15 * SECOND; diff --git a/src/handlers/handler.ts b/src/handlers/handler.ts index 9f17251..20ddd28 100644 --- a/src/handlers/handler.ts +++ b/src/handlers/handler.ts @@ -1,10 +1,15 @@ const _ = require("lodash"); -import { HANDLER_HEARBEAT_INTERVAL, HANDLER_TIMEOUT, Path } from "../constants"; -import ModuleBase from "../modules/moduleBase"; +import Ain from "@ainblockchain/ain-js"; +import { HANDLER_HEARBEAT_INTERVAL, Path } from "../constants"; +import Ainize from "../ainize"; -export default class Handler extends ModuleBase { +export default class Handler { isConnected: boolean = false; subscribeTable:any = {}; + ain: Ain; + constructor(ainize: Ainize) { + this.ain = ainize.ain; + } /** * Connect to ai Network event node. you should connect before subscibe. It will auto reconnect when disconnected. @@ -12,9 +17,8 @@ export default class Handler extends ModuleBase { */ async connect() { await this.ain.em.connect({ - handshakeTimeout: HANDLER_TIMEOUT, // Timeout in milliseconds for the web socket handshake request. heartbeatIntervalMs: HANDLER_HEARBEAT_INTERVAL, - }, this.disconnectedCallback); + }, this.disconnectedCallback.bind(this)); this.isConnected = true; };