Skip to content

Commit

Permalink
Wait until client is connected
Browse files Browse the repository at this point in the history
If sending after client exists but before it is connected (or while it
is reconnecting) then calling client.send will throw an error and not
save anything into SM state. So push these stanzas into pending to be
sent when coming online.

Not that this is not part of SM state and is not persisted at all, so a
full crash/reset will lose these stanzas right now, unlike un-acked SM stanzas.
  • Loading branch information
singpolyma committed Sep 18, 2024
1 parent b72f25c commit 75543e6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion snikket/streams/XmppJsStream.hx
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ class XmppJsStream extends GenericStream {
}

public function sendStanza(stanza:Stanza) {
if (client == null) {
if (client == null || client.status != "online") {
// TODO: these aren't part of the sm state so they can get lost
pending.push(convertFromStanza(stanza));
} else {
client.send(convertFromStanza(stanza));
Expand Down

0 comments on commit 75543e6

Please sign in to comment.