sendStanza method
- StanzaDetails details
Sends a stanza described by details
to the server. Until sent, the stanza is
kept in a queue, that is flushed after going online again. If Stream Management
is active, stanza's acknowledgement is tracked.
Implementation
// TODO(Unknown): if addId = false, the function crashes.
Future<XMLNode?> sendStanza(StanzaDetails details) async {
assert(
implies(
details.awaitable,
details.stanza.id != null && details.stanza.id!.isNotEmpty ||
details.addId,
),
'An awaitable stanza must have an id',
);
final completer = details.awaitable ? Completer<XMLNode>() : null;
final entry = StanzaQueueEntry(
details,
completer,
);
if (details.bypassQueue) {
await _sendStanzaImpl(entry);
} else {
await _stanzaQueue.enqueueStanza(entry);
}
return completer?.future;
}