Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Jan 16, 2025
1 parent 15e060e commit 26228e7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 27 deletions.
12 changes: 6 additions & 6 deletions packages/stream-management/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Indicates that the connection was resumed. When that happens the `online` event
const xmpp = client(...);
const {streamManagement} = xmpp;

streamManagement.on('resumed', ()) => {
streamManagement.on('resumed', () => {
console.log("session resumed");
}
});
```

### fail
Expand All @@ -37,9 +37,9 @@ Indicates that a stanza failed to send to the server and will not be retried.
const xmpp = client(...);
const {streamManagement} = xmpp;

streamManagement.on('fail', (stanza)) => {
streamManagement.on('fail', (stanza) => {
console.log("fail to send", stanza.toString());
}
});
```

### ack
Expand All @@ -50,9 +50,9 @@ Indicates that a stanza has been acknowledged by the server.
const xmpp = client(...);
const {streamManagement} = xmpp;

streamManagement.on('ack', (stanza)) => {
streamManagement.on('ack', (stanza) => {
console.log("stanza acknowledge by the server", stanza.toString());
}
});
```

## References
Expand Down
23 changes: 2 additions & 21 deletions packages/stream-management/stream-features.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,30 +131,11 @@ test("enable - failed", async () => {
test("stanza ack", async () => {
const { entity } = mockClient();

entity.mockInput(
<features xmlns="http://etherx.jabber.org/streams">
<sm xmlns="urn:xmpp:sm:3" />
</features>,
);

expect(await entity.catchOutgoing()).toEqual(
<enable xmlns="urn:xmpp:sm:3" resume="true" />,
);

entity.mockInput(
<enabled
xmlns="urn:xmpp:sm:3"
id="some-long-sm-id"
location="[2001:41D0:1:A49b::1]:9222"
resume="true"
/>,
);

await tick();
entity.streamManagement.enabled = true;

expect(entity.streamManagement.outbound).toBe(0);
expect(entity.streamManagement.outbound_q).toBeEmpty();
expect(entity.streamManagement.enabled).toBe(true);
// expect(entity.streamManagement.enabled).toBe(true);

await entity.send(<message id="a" />);

Expand Down
3 changes: 3 additions & 0 deletions test/stream-management.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ test("client retry stanzas", async () => {
),
stamp: datetime(),
});
// Do not close the stream so that stream resumption can happen
await xmpp._closeSocket();
await xmpp.disconnect();

const el = await promise_ack;
Expand All @@ -101,6 +103,7 @@ test(
<ping xmlns="urn:xmppp:ping" />
</iq>,
);

// Pretend we don't receive the ack by removing event listeners
// on the socket
xmpp._detachSocket();
Expand Down

0 comments on commit 26228e7

Please sign in to comment.