onConnectionEstablished method

  1. @override
void onConnectionEstablished(
  1. ConnectionInfo connectionInfo,
  2. String serverGreeting
)

Implementation

@override
void onConnectionEstablished(
    ConnectionInfo connectionInfo, String serverGreeting) {
  _serverInfo = ImapServerInfo(connectionInfo);
  final startIndex = serverGreeting.indexOf('[CAPABILITY ');
  if (startIndex != -1) {
    CapabilityParser.parseCapabilities(
        serverGreeting, startIndex + '[CAPABILITY '.length, _serverInfo);
  }
  if (_queue.isNotEmpty) {
    // this can happen when a connection was re-established, e.g. when trying to complete an IDLE connection
    for (final task in _queue) {
      try {
        task.completer.completeError('reconnect');
      } catch (e, s) {
        print('unable to completeError for task $task $e $s');
      }
    }
    _queue.clear();
  }
  // print('IMAP: got server greeting: $serverGreeting');
}