open method

void open()

Initializes transport to use and starts probe.

@api private

Implementation

void open() {
  var transport;
  if (rememberUpgrade != null &&
      priorWebsocketSuccess &&
      transports.contains('websocket')) {
    transport = 'websocket';
  } else if (transports.isEmpty) {
    // Emit error on next tick so it can be listened to
    Timer.run(() => emit('error', 'No transports available'));
    return;
  } else {
    transport = transports[0];
  }
  readyState = 'opening';

  // Retry with the next transport if the transport is disabled (jsonp: false)
  try {
    transport = createTransport(transport);
  } catch (e) {
    transports.removeAt(0);
    open();
    return;
  }

  transport.open();
  setTransport(transport);
}