diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2007-01-17 18:11:11 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2007-01-17 18:11:11 +0000 |
commit | e124e693704faa56ecf32ce2a243d0c3fa3a5e6e (patch) | |
tree | 071dcaa6edc458f9371289976a4537880e5bb005 /py/demo/Ice/async/Client.py | |
parent | Changed async demo (diff) | |
download | ice-e124e693704faa56ecf32ce2a243d0c3fa3a5e6e.tar.bz2 ice-e124e693704faa56ecf32ce2a243d0c3fa3a5e6e.tar.xz ice-e124e693704faa56ecf32ce2a243d0c3fa3a5e6e.zip |
Changed demo
Diffstat (limited to 'py/demo/Ice/async/Client.py')
-rw-r--r-- | py/demo/Ice/async/Client.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/py/demo/Ice/async/Client.py b/py/demo/Ice/async/Client.py new file mode 100644 index 00000000000..9590f67ca46 --- /dev/null +++ b/py/demo/Ice/async/Client.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 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 AMI_Hello_sayHelloI: + def ice_response(self): + pass + + def ice_exception(self, ex): + 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): + hello = Demo.HelloPrx.checkedCast(self.communicator().propertyToProxy('Hello.Proxy')) + if not hello: + print args[0] + ": invalid proxy" + return False + + menu() + + c = None + while c != 'x': + try: + c = raw_input("==> ") + if c == 'i': + hello.sayHello(0) + elif c == 'd': + hello.sayHello_async(AMI_Hello_sayHelloI(), 5000) + 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 True + +app = Client() +sys.exit(app.main(sys.argv, "config.client")) |