start method

void start()

Implementation

void start() async {
  _isActive = true;
  try {
    _channel = await platform.connect(config..resetSession());
    // It can happen that dispose was called while the future above hasn't completed yet
    // To prevent lingering connections we need to make sure that we disconnect cleanly
    if (!_isActive) {
      _cleanUp();
    } else {
      _channel!.stream.listen(_onData, onError: _onError, onDone: _onDone);
      _connectToStomp();
    }
  } catch (err) {
    _onError(err);
    if (config.reconnectDelay.inMilliseconds == 0) {
      _cleanUp();
    } else {
      if (err is TimeoutException) {
        config.onDebugMessage('Connection timed out...reconnecting');
      } else if (err is WebSocketChannelException) {
        config.onDebugMessage('Connection error...reconnecting');
      } else {
        config.onDebugMessage('Unknown connection error...reconnecting');
      }
      _onDone();
    }
  }
}