Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: delete Timeout #36

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ export const Path = {
}

export const SECOND = 1000;
export const HANDLER_TIMEOUT = 30 * SECOND;
export const HANDLER_HEARBEAT_INTERVAL = 15 * SECOND;
14 changes: 9 additions & 5 deletions src/handlers/handler.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
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.
* @returns Nothing.
*/
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;
};

Expand Down