clearTransport method

void clearTransport()

Clears listeners and timers associated with current transport.

@api private

Implementation

void clearTransport() {
  dynamic cleanup;

  var toCleanUp = cleanupFn.length;

  for (var i = 0; i < toCleanUp; i++) {
    cleanup = cleanupFn.removeAt(0);
    cleanup();
  }

  // silence further transport errors and prevent uncaught exceptions
  transport.on('error', (_) {});

  // ensure transport won't stay open
  transport.close();

  pingTimeoutTimer?.cancel();
}