source: doc/listings/xmppim/roster_client_set_name.py @ 174:c0f51d95bf0f

Last change on this file since 174:c0f51d95bf0f was 174:c0f51d95bf0f, checked in by Ralph Meijer <ralphm@…>, 8 years ago

Add support for adding and updating roster items.

Roster items can be added or updated by sending a roster set request using the
new wokkel.xmppim.RosterClientProtocol.setItem. It takes a RosterItem as
the only argument. Note that changes in presence subscriptions for the contact
need to be done using presence as provided by
wokkel.xmppim.PresenceProtocol.

Author: ralphm.
Fixes: #56.

File size: 493 bytes
Line 
1import sys
2from twisted.internet import reactor
3from twisted.words.protocols.jabber.jid import JID
4from wokkel.client import XMPPClient
5from wokkel.xmppim import RosterClientProtocol, RosterItem
6
7USER_JID, PASSWORD, CONTACT_JID, NAME = sys.argv[1:5]
8client = XMPPClient(JID(USER_JID), PASSWORD)
9roster = RosterClientProtocol()
10roster.setHandlerParent(client)
11
12d = roster.setItem(RosterItem(JID(CONTACT_JID), name=NAME))
13d.addBoth(lambda _: reactor.stop())
14
15client.startService()
16reactor.run()
Note: See TracBrowser for help on using the repository browser.