diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2006-11-17 16:38:04 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2006-11-17 16:38:04 +0000 |
commit | 07bc5c36dd039dd88ee105a9a254d92556d2df6c (patch) | |
tree | 82cf9419721c997bf0306568e7dae3f5873db88c /py/demo/Ice/async/Consumer.py | |
parent | Fixed build (diff) | |
download | ice-07bc5c36dd039dd88ee105a9a254d92556d2df6c.tar.bz2 ice-07bc5c36dd039dd88ee105a9a254d92556d2df6c.tar.xz ice-07bc5c36dd039dd88ee105a9a254d92556d2df6c.zip |
Added AMI/AMD demo
Diffstat (limited to 'py/demo/Ice/async/Consumer.py')
-rw-r--r-- | py/demo/Ice/async/Consumer.py | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/py/demo/Ice/async/Consumer.py b/py/demo/Ice/async/Consumer.py new file mode 100644 index 00000000000..d5959e9817f --- /dev/null +++ b/py/demo/Ice/async/Consumer.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2006 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, traceback, Ice + +Ice.loadSlice('Queue.ice') +import Demo + +class AMI_Queue_getI: + def ice_response(self, message): + print message + + def ice_exception(self, ex): + print ex + +def menu(): + print """ +usage: +g: get a message +x: exit +?: help +""" + +class Consumer(Ice.Application): + def run(self, args): + properties = self.communicator().getProperties() + refProperty = 'Queue.Proxy' + proxy = properties.getProperty(refProperty) + if len(proxy) == 0: + print args[0] + ": property `" + refProperty + "' not set" + return False + + queue = Demo.QueuePrx.checkedCast(self.communicator().stringToProxy(proxy)) + if not queue: + print args[0] + ": invalid proxy" + return False + + menu() + + c = None + while c != 'x': + try: + c = raw_input("==> ") + if c == 'g': + queue.get_async(AMI_Queue_getI()) + elif c == 'x': + pass # Nothing to do + elif c == '?': + menu() + else: + print "unknown command `" + c + "'" + menu() + except EOFError: + break + except Ice.Exception, ex: + print ex + + return True + +app = Consumer() +sys.exit(app.main(sys.argv, "config.client")) |