XMPP IQ (Info/  Query) Functions
make-iq-reply
8.12

XMPP IQ (Info/Query) Functions🔗ℹ

Navlost <racket at navlost dot eu>

 (require xmpp/iq) package: XMPP

This package implements functions for dealing with IQ (Info/Query) stanzas.

procedure

(make-iq-reply [#:type type] iq body ...)  (xexpr/c)

  type : string? = "result"
  iq : xexpr/c
  body : xexpr/c
Generates an xexpr which is a result stanza corresponding to iq with any extra arguments in the body of the stanza.

This is done by copying the id attribute, switching the to and from attributes and setting type=type (defaults to "result").

Examples:
; An example incoming IQ
> (define iq (string->xexpr
              (string-append
               "<iq type='get' id='abcde' "
               "to='user@example.net' from='user@example.com'>"
               "<query xmlns='http://jabber.org/protocol/disco#info'/>"
               "</iq>")))
; A result IQ based off the previous query.
> (make-iq-reply iq
                  '(query
                    ((xmlns "http://jabber.org/protocol/disco#info"))
                    (identity ((type "registered") (category "account")))))

'(iq

  ((type "result")

   (id "abcde")

   (from "user@example.net")

   (to "user@example.com"))

  (query

   ((xmlns "http://jabber.org/protocol/disco#info"))

   (identity ((type "registered") (category "account")))))