From de2ae140af81a55acb4d87824d5ef108c7b7b6e6 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 23 Sep 2024 23:05:31 -0500 Subject: [PATCH] Store pending stanzas along with SM data --- snikket/streams/XmppJsStream.hx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/snikket/streams/XmppJsStream.hx b/snikket/streams/XmppJsStream.hx index e1f08c5..3bea39c 100644 --- a/snikket/streams/XmppJsStream.hx +++ b/snikket/streams/XmppJsStream.hx @@ -190,6 +190,12 @@ class XmppJsStream extends GenericStream { if (initialSM != null) { final parsedSM = haxe.Json.parse(Bytes.ofData(initialSM).toString()); + final parsedPending: Null> = parsedSM.pending; + if (parsedPending != null) { + for (item in parsedPending) { + pending.push(XmppJsLtx.parse(item)); + } + } xmpp.streamManagement.id = parsedSM.id; xmpp.streamManagement.outbound = parsedSM.outbound; xmpp.streamManagement.inbound = parsedSM.inbound; @@ -297,12 +303,11 @@ class XmppJsStream extends GenericStream { public function sendStanza(stanza:Stanza) { 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)); - triggerSMupdate(); } + triggerSMupdate(); } public function newId():String { @@ -319,6 +324,7 @@ class XmppJsStream extends GenericStream { outbound: client.streamManagement.outbound, inbound: client.streamManagement.inbound, outbound_q: (client.streamManagement.outbound_q ?? []).map((stanza) -> stanza.toString()), + pending: pending.map((stanza) -> stanza.toString()) })).getData() } ); @@ -359,6 +365,7 @@ class XmppJsStream extends GenericStream { while ((item = pending.shift()) != null) { client.send(item); } + triggerSMupdate(); trigger("status/online", { jid: jid.toString(), resumed: resumed }); }