Skip to content

Commit

Permalink
Detect resume sooner
Browse files Browse the repository at this point in the history
Instead of waiting for a stanza, we can catch the first non-SM item
after online, which should be the stream features usually.
  • Loading branch information
singpolyma committed Oct 2, 2024
1 parent fcea073 commit be7f78b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion snikket/streams/XmppJsStream.hx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern class XmppJsClient {
get: (String, String, ({stanza: XmppJsXml})->Any)->Void,
set: (String, String, ({stanza: XmppJsXml})->Any)->Void,
};
var middleware: { use:(({stanza: XmppJsXml})->Void)->Void };
var streamFeatures: { use:(String,String,({}, ()->Void, XmppJsXml)->Void)->Void };
var streamManagement: { id:String, outbound: Int, inbound: Int, outbound_q: Array<XmppJsXml>, enabled: Bool, allowResume: Bool };
var sasl2: Dynamic;
Expand Down Expand Up @@ -216,7 +217,8 @@ class XmppJsStream extends GenericStream {
this.state.event("connection-closed");
});

xmpp.on("stanza", function (stanza) {
xmpp.middleware.use(function (data) {
if (data.stanza.attrs.xmlns == "urn:xmpp:sm:3") return;
if (xmpp.status == "online" && this.state.can("connection-success")) {
resumed = xmpp.streamManagement.enabled && xmpp.streamManagement.id != null && xmpp.streamManagement.id != "";
if (xmpp.jid == null) {
Expand All @@ -226,6 +228,9 @@ class XmppJsStream extends GenericStream {
}
this.state.event("connection-success");
}
});

xmpp.on("stanza", function (stanza) {
this.onStanza(convertToStanza(stanza));
triggerSMupdate();
});
Expand Down

0 comments on commit be7f78b

Please sign in to comment.