- class slixmpp.stanza.Iq(*args, recv=False, **kwargs)[source]#
XMPP <iq> stanzas, or info/query stanzas, are XMPP’s method of requesting and modifying information, similar to HTTP’s GET and POST methods.
Each <iq> stanza must have an ‘id’ value which associates the stanza with the response stanza. XMPP entities must always be given a response <iq> stanza with a type of ‘result’ after sending a stanza of type ‘get’ or ‘set’.
Most uses cases for <iq> stanzas will involve adding a <query> element whose namespace indicates the type of information desired. However, some custom XMPP applications use <iq> stanzas as a carrier stanza for an application-specific protocol instead.
Example <iq> Stanzas:
<iq to="firstname.lastname@example.org" type="get" id="314"> <query xmlns="http://jabber.org/protocol/disco#items" /> </iq> <iq to="user@localhost" type="result" id="17"> <query xmlns='jabber:iq:roster'> <item email@example.com' name='John Doe' subscription='both'> <group>Friends</group> </item> </query> </iq>
- Stanza Interface:
query: The namespace of the <query> element if one exists.
types: May be one of: get, set, result, or error.
Create a new <iq> stanza replying to
Sets the ‘type’ to ‘result’ in addition to the default StanzaBase.reply behavior.
clear (bool) – Indicates if existing content should be removed before replying. Defaults to True.
- send(callback=None, timeout=None, timeout_callback=None)[source]#
Send an <iq> stanza over the XML stream.
A callback handler can be provided that will be executed when the Iq stanza’s result reply is received.
Returns a future which result will be set to the result Iq if it is of type ‘get’ or ‘set’ (when it is received), or a future with the result set to None if it has another type.
callback (function) – Optional reference to a stream handler function. Will be executed when a reply stanza is received.
timeout (int) – The length of time (in seconds) to wait for a response before the timeout_callback is called, instead of the regular callback
timeout_callback (function) – Optional reference to a stream handler function. Will be executed when the timeout expires before a response has been received for the originally-sent IQ stanza.
- Return type
Set the XML contents of the <iq> stanza.
value (list or XML object) – An XML object or a list of XML objects to use as the <iq> stanza’s contents
Add or modify a <query> element.
Query elements are differentiated by their namespace.
value (str) – The namespace of the <query> element.