Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Jan 16, 2025
1 parent 0a32122 commit 1431160
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 116 deletions.
16 changes: 7 additions & 9 deletions packages/stream-management/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export default function streamManagement({
entity.on("disconnect", () => {
clearTimeout(timeoutTimeout);
clearTimeout(requestAckTimeout);
sm.removeListener("stanza", scheduleRequestAck);
});

async function resumed(resumed) {
Expand All @@ -80,6 +79,12 @@ export default function streamManagement({
entity._ready(true);
}

function failed() {
sm.enabled = false;
sm.id = "";
failQueue();
}

function ackQueue(n) {
const oldOutbound = sm.outbound;
for (let i = 0; i < +n - oldOutbound; i++) {
Expand All @@ -97,18 +102,11 @@ export default function streamManagement({
sm.outbound = 0;
}

function failed() {
sm.enabled = false;
sm.id = "";
failQueue();
}

function enabled({ id, max }) {
sm.enabled = true;
sm.id = id;
sm.max = max;
scheduleRequestAck();
sm.on("stanza", scheduleRequestAck);
}

entity.on("online", () => {
Expand All @@ -129,8 +127,8 @@ export default function streamManagement({
});

middleware.use((context, next) => {
clearTimeout(timeoutTimeout);
const { stanza } = context;
clearTimeout(timeoutTimeout);
if (["presence", "message", "iq"].includes(stanza.name)) {
sm.inbound += 1;
} else if (stanza.is("r", NS)) {
Expand Down
106 changes: 0 additions & 106 deletions test/stream-management.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/stream-management.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ test(
xmpp = client({ credentials, service: domain });
xmpp.streamManagement.timeout = 10;
xmpp.streamManagement.debounceAckRequest = 1;
debug(xmpp, true);
debug(xmpp);

const promise_resumed = promise(xmpp.streamManagement, "resumed");
await xmpp.start();
Expand Down

0 comments on commit 1431160

Please sign in to comment.