Initial import to Tizen
[profile/ivi/python-twisted.git] / doc / core / howto / listings / pb / pb1client.py
1 #!/usr/bin/env python
2
3 # Copyright (c) Twisted Matrix Laboratories.
4 # See LICENSE for details.
5
6 from twisted.spread import pb
7 from twisted.internet import reactor
8
9 def main():
10     factory = pb.PBClientFactory()
11     reactor.connectTCP("localhost", 8800, factory)
12     def1 = factory.getRootObject()
13     def1.addCallbacks(got_obj1, err_obj1)
14     reactor.run()
15
16 def err_obj1(reason):
17     print "error getting first object", reason
18     reactor.stop()
19
20 def got_obj1(obj1):
21     print "got first object:", obj1
22     print "asking it to getTwo"
23     def2 = obj1.callRemote("getTwo")
24     def2.addCallbacks(got_obj2)
25
26 def got_obj2(obj2):
27     print "got second object:", obj2
28     print "telling it to do three(12)"
29     obj2.callRemote("three", 12)
30
31 main()