// ********************************************************************** // // 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 #include #include 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; }