diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2008-01-16 10:51:58 -0330 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2008-01-16 10:51:58 -0330 |
commit | 56edc882ca5c9fb83001c107d1cf411a3815b9ec (patch) | |
tree | bb040a6650459b4b294026068b566cc3fb1cbc5a /cpp/demo/Ice/multicast/Server.cpp | |
parent | Partial fix for bug #2642 (diff) | |
download | ice-56edc882ca5c9fb83001c107d1cf411a3815b9ec.tar.bz2 ice-56edc882ca5c9fb83001c107d1cf411a3815b9ec.tar.xz ice-56edc882ca5c9fb83001c107d1cf411a3815b9ec.zip |
Added multicast discovery demo
Diffstat (limited to 'cpp/demo/Ice/multicast/Server.cpp')
-rw-r--r-- | cpp/demo/Ice/multicast/Server.cpp | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/cpp/demo/Ice/multicast/Server.cpp b/cpp/demo/Ice/multicast/Server.cpp index ade188d45db..b6b42dff1cf 100644 --- a/cpp/demo/Ice/multicast/Server.cpp +++ b/cpp/demo/Ice/multicast/Server.cpp @@ -8,11 +8,44 @@ // ********************************************************************** #include <Ice/Ice.h> -#include <HelloI.h> + +#include <Discovery.h> +#include <Hello.h> using namespace std; +using namespace Demo; + +class HelloI : public Hello +{ +public: + + virtual void + sayHello(const Ice::Current&) const + { + cout << "Hello World!" << endl; + } +}; + +class DiscoverI : public Discover +{ +public: + + DiscoverI(const Ice::ObjectPrx& obj) : _obj(obj) + { + } + + virtual void + lookup(const DiscoverReplyPrx& reply, const Ice::Current&) + { + reply->reply(_obj); + } + +private: + + const Ice::ObjectPrx _obj; +}; -class MulticastServer : public Ice::Application +class HelloServer : public Ice::Application { public: @@ -22,22 +55,22 @@ public: int main(int argc, char* argv[]) { - MulticastServer app; + HelloServer app; return app.main(argc, argv, "config.server"); } int -MulticastServer::run(int argc, char* argv[]) +HelloServer::run(int argc, char* argv[]) { - if(argc > 1) - { - cerr << appName() << ": too many arguments" << endl; - return EXIT_FAILURE; - } - Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Hello"); - adapter->add(new HelloI, communicator()->stringToIdentity("hello")); + Ice::ObjectAdapterPtr discoverAdapter = communicator()->createObjectAdapter("Discover"); + + Ice::ObjectPrx hello = adapter->addWithUUID(new HelloI); + discoverAdapter->add(new DiscoverI(hello), communicator()->stringToIdentity("discover")); + + discoverAdapter->activate(); adapter->activate(); + communicator()->waitForShutdown(); return EXIT_SUCCESS; } |