Skip to content

Commit

Permalink
client: Answer to ping requests
Browse files Browse the repository at this point in the history
Closes #629
  • Loading branch information
sonnyp committed Jan 6, 2025
1 parent b25e478 commit ff61892
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ function client(options = {}) {
resource,
);

iqCallee?.get("urn:xmpp:ping", "ping", () => {
return {};
});

return Object.assign(entity, {
entity,
reconnect,
Expand Down
15 changes: 15 additions & 0 deletions packages/client/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { mockClient, promise } from "@xmpp/test";

test("answers to ping requests", async () => {
const { entity } = mockClient();

entity.mockInput(
<iq to="foo@bar" from="bar@foo" id="foo" type="get">
<ping xmlns="urn:xmpp:ping" />
</iq>,
);

expect(await promise(entity, "send")).toEqual(
<iq to="bar@foo" from="foo@bar" id="foo" type="result" />,
);
});

0 comments on commit ff61892

Please sign in to comment.