setTransport method

void setTransport(
  1. dynamic transport
)

Sets the current transport. Disables the existing one (if any).

@api private

Implementation

void setTransport(transport) {
  _logger.fine('setting transport ${transport.name}');

  if (this.transport != null) {
    _logger.fine('clearing existing transport ${this.transport!.name}');
    this.transport!.clearListeners();
  }

  // set up transport
  this.transport = transport;

  // set up transport listeners
  transport
    ..on('outOfBand', (data) => onOutOfBand(data))
    ..on('drain', (_) => onDrain())
    ..on('packet', (packet) => onPacket(packet))
    ..on('error', (e) => onError(e))
    ..on('close', (_) => onClose('transport close'));
}