[PyXMPP] Custom protocol: message- or IQ-based?

Jacek Konieczny jajcus at jajcus.net
Mon Feb 19 09:53:09 CET 2007


On Sun, Feb 18, 2007 at 08:55:02PM +0100, cyberco wrote:
> CODE==================================
> 
> iq = Iq(from_jid=fromJid, to_jid=toJid, stanza_type='get')
> queryNode = iq.new_query(ns_uri='http://www.company.com/app')
> yamlNode = libxml2.newNode('yaml')
> queryNode.addChild(yamlNode)
> iq.set_content(queryNode)
  ^^^^^^^^^^^^^^^^^^^^^^^^^

This is not needed. .new_query() method already adds the node to the
stanza.
 
> /CODE==================================
> 
> This results in the following IQ packet:
> 
> <iq from="x at x.com/home" to="y at y.com" type="get" id="979308"><query xmlns="
> http://www.company.com/app"><yaml/></query></iq>

Seems ok, except the "to" jid. It lacks resource (the part after "/"),
so it is directed to server, not client connected to the "y at y.com"
account.

> and the following error:
> 
> <query xmlns="http://www.company.com/app"><yaml/></query>

Where is the error? This is only the copy of stanza content. I guess
that was inside of some <iq type="error"/> stanza. You should paste
that whole stanza here.

> I wonder if the namespace is the problem.

No it is not.

> Can I just use any namespace as
> long as both clients know it?

Yes.

> A disadvantage seems to be that IQ packets are not stored if the other is
> offline. Any other disadvantages?

You need to know full destination JID (including the resource part) to
send IQ stanzas to other client. Generally that means presence tracking,
so you know what resources of the destination account are connected.
<message/> stanzas are sent to the highest priority resource if sent to
bare JID (without resource).

Greets,
        Jacek


More information about the PyXMPP mailing list