| 1 |
# Copyright (c) Twisted Matrix Laboratories. |
| 2 |
# See LICENSE for details. |
| 3 |
|
| 4 |
|
| 5 |
from pbecho import DefinedError |
| 6 |
|
| 7 |
from twisted.cred.credentials import UsernamePassword |
| 8 |
from twisted.internet import reactor |
| 9 |
from twisted.spread import pb |
| 10 |
|
| 11 |
|
| 12 |
def success(message): |
| 13 |
print("Message received:", message) |
| 14 |
# reactor.stop() |
| 15 |
|
| 16 |
|
| 17 |
def failure(error): |
| 18 |
t = error.trap(DefinedError) |
| 19 |
print("error received:", t) |
| 20 |
reactor.stop() |
| 21 |
|
| 22 |
|
| 23 |
def connected(perspective): |
| 24 |
perspective.callRemote("echo", "hello world").addCallbacks(success, failure) |
| 25 |
perspective.callRemote("error").addCallbacks(success, failure) |
| 26 |
print("connected.") |
| 27 |
|
| 28 |
|
| 29 |
factory = pb.PBClientFactory() |
| 30 |
reactor.connectTCP("localhost", pb.portno, factory) |
| 31 |
factory.login(UsernamePassword("guest", "guest")).addCallbacks(connected, failure) |
| 32 |
|
| 33 |
reactor.run() |