diff options
author | Joe George <joe@zeroc.com> | 2015-03-03 17:30:50 -0500 |
---|---|---|
committer | Joe George <joe@zeroc.com> | 2015-05-12 11:41:55 -0400 |
commit | d35bb9f5c19e34aee31f83d445695a8186ef675e (patch) | |
tree | d5324eaf44f5f9776495537c51653f50a66a7237 /py/demo/Ice/async/Client.py | |
download | ice-d35bb9f5c19e34aee31f83d445695a8186ef675e.tar.bz2 ice-d35bb9f5c19e34aee31f83d445695a8186ef675e.tar.xz ice-d35bb9f5c19e34aee31f83d445695a8186ef675e.zip |
Ice 3.4.2 Source Distributionv3.4.2
Diffstat (limited to 'py/demo/Ice/async/Client.py')
-rwxr-xr-x | py/demo/Ice/async/Client.py | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/py/demo/Ice/async/Client.py b/py/demo/Ice/async/Client.py new file mode 100755 index 00000000000..06a654a9613 --- /dev/null +++ b/py/demo/Ice/async/Client.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import sys, os, traceback, threading, Ice + +Ice.loadSlice('Hello.ice') +import Demo + +class Callback: + def response(self): + pass + + def exception(self, ex): + if isinstance(ex, Demo.RequestCanceledException): + print "Demo.RequestCanceledException" + else: + print "sayHello AMI call failed:" + print ex + +def menu(): + print """ +usage: +i: send immediate greeting +d: send delayed greeting +s: shutdown server +x: exit +?: help +""" + +class Client(Ice.Application): + def run(self, args): + if len(args) > 1: + print self.appName() + ": too many arguments" + return 1 + + hello = Demo.HelloPrx.checkedCast(self.communicator().propertyToProxy('Hello.Proxy')) + if not hello: + print args[0] + ": invalid proxy" + return 1 + + menu() + + c = None + while c != 'x': + try: + c = raw_input("==> ") + if c == 'i': + hello.sayHello(0) + elif c == 'd': + cb = Callback() + hello.begin_sayHello(5000, cb.response, cb.exception) + elif c == 's': + hello.shutdown() + elif c == 'x': + pass # Nothing to do + elif c == '?': + menu() + else: + print "unknown command `" + c + "'" + menu() + except EOFError: + break + except KeyboardInterrupt: + break + except Ice.Exception, ex: + print ex + + return 0 + +app = Client() +sys.exit(app.main(sys.argv, "config.client")) |