Rename to slixmpp
[slixmpp.git] / examples / rpc_async.py
blobedbad554fea2895edb0193b96195f2c1bce84ace
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 """
5 Slixmpp: The Slick XMPP Library
6 Copyright (C) 2011 Dann Martens
7 This file is part of Slixmpp.
9 See the file LICENSE for copying permission.
10 """
12 from slixmpp.plugins.xep_0009.remote import Endpoint, remote, Remote, \
13 ANY_ALL, Future
14 import time
16 class Boomerang(Endpoint):
18 def FQN(self):
19 return 'boomerang'
21 @remote
22 def throw(self):
23 print "Duck!"
27 def main():
29 session = Remote.new_session('kangaroo@xmpp.org/rpc', '*****')
31 session.new_handler(ANY_ALL, Boomerang)
33 boomerang = session.new_proxy('kangaroo@xmpp.org/rpc', Boomerang)
35 callback = Future()
37 boomerang.async(callback).throw()
39 time.sleep(10)
41 session.close()
45 if __name__ == '__main__':
46 main()