virtual-websocket-client.d.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { IResponseMessage } from '../typings/realtime';
  2. import { RealtimeListener } from './listener';
  3. import { IWSSendOptions } from './websocket-client';
  4. import { IWatchOptions } from '../typings/index';
  5. interface IVirtualWebSocketClientConstructorOptions extends IWatchOptions {
  6. envId?: string;
  7. collectionName: string;
  8. query: string;
  9. limit?: number;
  10. orderBy?: Record<string, string>;
  11. send: <T = any>(opts: IWSSendOptions) => Promise<T>;
  12. login: (envId?: string, refresh?: boolean) => Promise<any>;
  13. isWSConnected: () => boolean;
  14. onceWSConnected: () => Promise<void>;
  15. getWaitExpectedTimeoutLength: () => number;
  16. onWatchStart: (client: VirtualWebSocketClient, queryID: string) => void;
  17. onWatchClose: (client: VirtualWebSocketClient, queryID: string) => void;
  18. debug?: boolean;
  19. }
  20. export declare class VirtualWebSocketClient {
  21. watchId: string;
  22. private envId?;
  23. private collectionName;
  24. private query;
  25. private limit;
  26. private orderBy;
  27. private send;
  28. private login;
  29. private isWSConnected;
  30. private onceWSConnected;
  31. private getWaitExpectedTimeoutLength;
  32. private onWatchStart;
  33. private onWatchClose;
  34. private debug?;
  35. listener: RealtimeListener;
  36. private watchStatus;
  37. private _availableRetries;
  38. private _ackTimeoutId?;
  39. private _initWatchPromise?;
  40. private _rebuildWatchPromise?;
  41. private sessionInfo?;
  42. private _waitExpectedTimeoutId?;
  43. constructor(options: IVirtualWebSocketClientConstructorOptions);
  44. private _login;
  45. private initWatch;
  46. private rebuildWatch;
  47. private handleWatchEstablishmentError;
  48. private closeWatch;
  49. private scheduleSendACK;
  50. private clearACKSchedule;
  51. private sendACK;
  52. private handleCommonError;
  53. private useRetryTicket;
  54. private handleServerEvents;
  55. private _handleServerEvents;
  56. private _postHandleServerEventsValidityCheck;
  57. private clearWaitExpectedEvent;
  58. onMessage(msg: IResponseMessage): void;
  59. closeWithError(error: any): void;
  60. pause(): void;
  61. resume(): Promise<void>;
  62. }
  63. export {};