forked from xmpppy/xmpppy
-
Notifications
You must be signed in to change notification settings - Fork 13
Advanced documentation
CyrilPeponnet edited this page Sep 23, 2014
·
1 revision
To write a programs using XMPP technology you must understand the basic principles of it. Xmpppy uses it's own implementation of XML handling procedures - so you should get used to it.
Prototype:
Node.__init__(name='', attrs={}, payload=[], parent=None, node=None)
Note that 'name' argument really consists of namespace and node name, space separated.
Example:
node=Node('jabber:client message', attrs={'to':'[email protected]'},payload=[Node('body',payload=['Hello target!'])])
or
node=Node('jabber:client message')
node['to']='[email protected]'
node.NT.body='Hello target!'
NT stands for 'New Tag' and explicitly adds new child to the current node. Also the T can be used. That means 'find Tag' but if tag exists it acts just like NT otherwise.
Uses similar syntax. We will use 'node' attribute now:
Prototype:
Protocol.__init__(name=None, to=None, typ=None, frm=None, attrs={}, payload=[], timestamp=None, xmlns='jabber:client', node=None)
Example :
p=Protocol(node=node)
or
proto=Protocol('message',to='[email protected]',payload=[Node('body',payload=['Hello target!'])])
or
proto=Protocol('message',to='[email protected]')
proto.NT.body='Hello target!'
Prototype:
Message.__init__(to=None, body=None, typ=None, subject=None, attrs={}, frm=None, payload=[], timestamp=None, xmlns='jabber:client', node=None)
Example:
m=Message(node=proto)
or
m=Message('[email protected]','Hello target!')
Prototype:
Iq.__init__(typ=None, queryNS=None, attrs={}, to=None, frm=None, payload=[], xmlns='jabber:client', node=None)
Example:
iq=Iq('set',NS_AUTH,payload=[Node('username',payload=['user']),Node('password',payload=['secret'])])
or
iq=Iq('set',NS_AUTH)
iq.T.query.NT.username='user'
iq.T.query.NT.password='secret'
or
iq=Iq('set',NS_AUTH)
iq.T.query.T.username='user'
iq.T.query.T.password='secret'
As I already noted - 'T' acts just like 'NT' if tag doesn't exists.
Prototype:
Presence.__init__(to=None, typ=None, priority=None, show=None, status=None, attrs={}, frm=None, timestamp=None, payload=[], xmlns='jabber:client', node=None)
Example:
pres=Presence(priority=5, show='xa',status="I'm away from my computer")
or
pres=Presence()
pres.setPriority(5) pres.setShow('xa') pres.setStatus("I'm away from my computer") pres.setTimestamp()
or
pres=Presence()
pres.T.priority=5 pres.T.show='xa' pres.T.status="I'm away from my computer" pres.setTimestamp()