Next: , Previous: Roster structure, Up: Hacking and extending



16.3 Listening for new requests

To listen for new IQ requests, add the appropriate entry in jabber-iq-get-xmlns-alist or jabber-iq-set-xmlns-alist. The key is the namespace of the request, and the value is a function that takes one argument, the entire IQ stanza in list format. jabber-process-iq reads these alists to determine which function to call on incoming packets.

For example, the Ad-Hoc Commands module contains the following:

     (add-to-list 'jabber-iq-set-xmlns-alist
     	     (cons "http://jabber.org/protocol/commands" 'jabber-ahc-process))

To send a response to an IQ request, use (jabber-send-iq sender "result" query nil nil nil nil id), where query is the query in list format. jabber-send-iq will encapsulate the query in an IQ packet with the specified id.

To return an error to the Jabber entity that sent the query, use jabber-signal-error. The signal is caught by jabber-process-iq, which takes care of sending the error.