diff options
Diffstat (limited to 'cpp/demo/Ice/session/Server.cpp')
-rw-r--r-- | cpp/demo/Ice/session/Server.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/cpp/demo/Ice/session/Server.cpp b/cpp/demo/Ice/session/Server.cpp new file mode 100644 index 00000000000..156ce0a148f --- /dev/null +++ b/cpp/demo/Ice/session/Server.cpp @@ -0,0 +1,62 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2005 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 <Ice/Ice.h> +#include <HelloSessionManagerI.h> + +using namespace std; +using namespace Demo; + +int +run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) +{ + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("SessionManager"); + SessionManagerIPtr manager = new HelloSessionManagerI; + Ice::ObjectPtr object = new HelloSessionManagerI; + adapter->add(object, Ice::stringToIdentity("SessionManager")); + adapter->activate(); + communicator->waitForShutdown(); + manager->destroy(); + return EXIT_SUCCESS; +} + +int +main(int argc, char* argv[]) +{ + int status; + Ice::CommunicatorPtr communicator; + + try + { + Ice::PropertiesPtr properties = Ice::createProperties(); + properties->load("config"); + communicator = Ice::initializeWithProperties(argc, argv, properties); + status = run(argc, argv, communicator); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } + + if(communicator) + { + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } + } + + return status; +} |