diff options
author | Marc Laukien <marc@zeroc.com> | 2005-02-05 18:22:55 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2005-02-05 18:22:55 +0000 |
commit | 0ac9eb8d52a88ac89b7118f99902636b8f13d414 (patch) | |
tree | e1e50870cf3208b666637ddf2fba8a240bb00784 /cpp/demo/Ice/bidir/Client.cpp | |
parent | removing call to startSeq/endSeq for sequence of fixed-length type (diff) | |
download | ice-0ac9eb8d52a88ac89b7118f99902636b8f13d414.tar.bz2 ice-0ac9eb8d52a88ac89b7118f99902636b8f13d414.tar.xz ice-0ac9eb8d52a88ac89b7118f99902636b8f13d414.zip |
connection->setAdapter and bidir demo
Diffstat (limited to 'cpp/demo/Ice/bidir/Client.cpp')
-rw-r--r-- | cpp/demo/Ice/bidir/Client.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/cpp/demo/Ice/bidir/Client.cpp b/cpp/demo/Ice/bidir/Client.cpp new file mode 100644 index 00000000000..6790702e6e6 --- /dev/null +++ b/cpp/demo/Ice/bidir/Client.cpp @@ -0,0 +1,73 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2004 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. +// +// ********************************************************************** + +#include <IceUtil/UUID.h> +#include <Ice/Application.h> +#include <Callback.h> + +using namespace std; +using namespace Ice; +using namespace Demo; + +class CallbackReceiverI : public CallbackReceiver +{ +public: + + virtual void + callback(Int num, const Current&) + { + cout << "received callback #" << num << endl; + } +}; + +class CallbackClient : public Application +{ +public: + + virtual int run(int, char*[]); +}; + +int +main(int argc, char* argv[]) +{ + CallbackClient app; + return app.main(argc, argv, "config"); +} + +int +CallbackClient::run(int argc, char* argv[]) +{ + PropertiesPtr properties = communicator()->getProperties(); + const char* proxyProperty = "Callback.Client.CallbackServer"; + std::string proxy = properties->getProperty(proxyProperty); + if(proxy.empty()) + { + cerr << appName() << ": property `" << proxyProperty << "' not set" << endl; + return EXIT_FAILURE; + } + + CallbackSenderPrx server = CallbackSenderPrx::checkedCast(communicator()->stringToProxy(proxy)); + if(!server) + { + cerr << appName() << ": invalid proxy" << endl; + return EXIT_FAILURE; + } + + ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Client"); + Identity ident; + ident.name = IceUtil::generateUUID(); + ident.category = ""; + adapter->add(new CallbackReceiverI, ident); + adapter->activate(); + server->ice_connection()->setAdapter(adapter); + server->addClient(ident); + communicator()->waitForShutdown(); + + return EXIT_SUCCESS; +} |