VirtualWebSocketClient constructor

VirtualWebSocketClient({
  1. String? envId,
  2. String? collectionName,
  3. String? query,
  4. int? limit,
  5. Map<String, String>? orderBy,
  6. required SendFunc send,
  7. required LoginFunc login,
  8. required IsWSConnectedFunc isWSConnected,
  9. required OnceWSConnectedFunc onceWSConnected,
  10. required GetWaitExpectedTimeoutLengthFunc getWaitExpectedTimeoutLength,
  11. required WatchStartCallback onWatchStart,
  12. required WatchCloseCallback onWatchClose,
  13. Function? onChange,
  14. Function? onError,
  15. bool? debug,
})

Implementation

VirtualWebSocketClient({
  String? envId,
  String? collectionName,
  String? query,
  int? limit,
  Map<String, String>? orderBy,
  required SendFunc send,
  required LoginFunc login,
  required IsWSConnectedFunc isWSConnected,
  required OnceWSConnectedFunc onceWSConnected,
  required GetWaitExpectedTimeoutLengthFunc getWaitExpectedTimeoutLength,
  required WatchStartCallback onWatchStart,
  required WatchCloseCallback onWatchClose,
  Function? onChange,
  Function? onError,
  bool? debug,
}) {
  this.watchId =
      'watchid_${DateTime.now().millisecondsSinceEpoch}_${Random().nextDouble()}';
  this._envId = envId;
  this._collectionName = collectionName;
  this._query = query;
  this._limit = limit;
  this._orderBy = orderBy;
  this._send = send;
  this._login = login;
  this._isWSConnected = isWSConnected;
  this._onceWSConnected = onceWSConnected;
  this._getWaitExpectedTimeoutLength = getWaitExpectedTimeoutLength;
  this._onWatchStart = onWatchStart;
  this._onWatchClose = onWatchClose;
  this._debug = debug;

  this._availableRetries = AvailableRetries(
    initWatch: DEFAULT_MAX_AUTO_RETRY_ON_ERROR,
    rebuildWatch: DEFAULT_MAX_AUTO_RETRY_ON_ERROR,
    checkLast: DEFAULT_MAX_SEND_ACK_AUTO_RETRY_ON_ERROR,
  );

  this.listener = RealtimeListener(
    close: this._closeWatch,
    onChange: onChange,
    onError: onError,
  );

  this._initWatch();
}