idleStart method
Switches to IDLE mode.
Requires a mailbox to be selected and the mail service to support IDLE.
Compare idleDone
Implementation
Future<void> idleStart() {
if (!isConnected) {
throw ImapException(this, 'idleStart failed: client is not connected');
}
if (!isLoggedIn) {
throw ImapException(this, 'idleStart failed: user not logged in');
}
if (_selectedMailbox == null) {
print('$logName: idleStart(): ERROR: no mailbox selected');
return Future.value();
}
if (_isInIdleMode) {
logApp('Warning: idleStart() called but client is already in IDLE mode.');
return Future.value();
}
final cmd = Command(
'IDLE',
writeTimeout: defaultWriteTimeout,
);
final task = CommandTask(cmd, nextId(), NoopParser(this, _selectedMailbox));
_tasks[task.id] = task;
_idleCommandTask = task;
final result = sendCommandTask(task, returnCompleter: false);
_isInIdleMode = true;
return result;
}