mezon-js 2.15.43 → 2.15.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.ts CHANGED
@@ -21,6 +21,12 @@ export declare const ConnectionState: {
21
21
  readonly CONNECTED: "connected";
22
22
  };
23
23
  export type ConnectionStateType = (typeof ConnectionState)[keyof typeof ConnectionState];
24
+ export interface AutoReconnectOptions {
25
+ enabled?: boolean;
26
+ maxAttempts?: number;
27
+ baseDelayMs?: number;
28
+ maxDelayMs?: number;
29
+ }
24
30
  /** A client for Mezon server. */
25
31
  export declare class Client {
26
32
  readonly serverkey: string;
@@ -34,17 +40,33 @@ export declare class Client {
34
40
  private _heartbeatTimer?;
35
41
  private _connectTimeoutTimer?;
36
42
  private _connectPromise?;
43
+ private _connectReject?;
44
+ private _hasConnectedOnce;
37
45
  private readonly transport;
46
+ private _autoReconnect;
47
+ private _maxReconnectAttempts;
48
+ private _reconnectBaseDelayMs;
49
+ private _reconnectMaxDelayMs;
50
+ private _reconnectAttempts;
51
+ private _reconnectTimer?;
52
+ private _lastConnectArgs?;
53
+ private _intentionallyClosed;
38
54
  host: string;
39
55
  port: string;
40
56
  useSSL: boolean;
41
57
  constructor(serverkey?: string, host?: string, port?: string, useSSL?: boolean, timeout?: number, autoFallbackHttp?: boolean);
42
58
  isOpen(): boolean;
43
59
  connect(session_id: string, url: string, createStatus?: boolean, verbose?: boolean, connectTimeoutMs?: number): Promise<void>;
60
+ setAutoReconnect(options: AutoReconnectOptions): void;
61
+ disconnect(fireDisconnectEvent?: boolean): void;
62
+ private scheduleReconnect;
63
+ private clearReconnectTimer;
44
64
  private pingPong;
45
65
  private startHeartbeatLoop;
46
66
  private stopHeartbeatLoop;
47
67
  private clearConnectTimeout;
68
+ private markDisconnected;
69
+ onconnect(evt: Event): void;
48
70
  onreconnect(evt: Event): void;
49
71
  ondisconnect(evt: Event): void;
50
72
  onerror(evt: Event): void;
@@ -0,0 +1,13 @@
1
+ type Fetcher = typeof fetch;
2
+ /**
3
+ * Set a custom fetch strategy for mezon-js API calls
4
+ * @param customFetcher - A fetch-compatible function
5
+ */
6
+ export declare const setFetchStrategy: (customFetcher: Fetcher) => void;
7
+ export declare const resetFetchStrategy: () => void;
8
+ /**
9
+ * Get the current fetch strategy
10
+ * @returns The current fetcher function
11
+ */
12
+ export declare const getFetcher: () => Fetcher;
13
+ export {};