summaryrefslogtreecommitdiff
path: root/cppe/demo/IceE/minimal/Client.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2008-06-03 19:32:20 -0700
committerMark Spruiell <mes@zeroc.com>2008-06-03 19:32:20 -0700
commit3d649bed4328992f41f567136025f58a019a5159 (patch)
tree470be901fbbfe5c6cd4269884412b0d36b48dc92 /cppe/demo/IceE/minimal/Client.cpp
parentlocal interface fixes for slice2javae (diff)
downloadice-3d649bed4328992f41f567136025f58a019a5159.tar.bz2
ice-3d649bed4328992f41f567136025f58a019a5159.tar.xz
ice-3d649bed4328992f41f567136025f58a019a5159.zip
Various Ice-E fixes:
- Bug fix in slice2javae for local interfaces/classes - Added Ice.LocalObjectHolder - Reviewed Java/C++ demos and aligned with Ice - Source code clean up (removed tabs, etc.)
Diffstat (limited to 'cppe/demo/IceE/minimal/Client.cpp')
-rw-r--r--cppe/demo/IceE/minimal/Client.cpp117
1 files changed, 27 insertions, 90 deletions
diff --git a/cppe/demo/IceE/minimal/Client.cpp b/cppe/demo/IceE/minimal/Client.cpp
index a44b0ffeb55..4ab546b0d36 100644
--- a/cppe/demo/IceE/minimal/Client.cpp
+++ b/cppe/demo/IceE/minimal/Client.cpp
@@ -13,111 +13,48 @@
using namespace std;
using namespace Demo;
-void
-menu()
-{
- printf("usage:\nh: say hello\nx: exit\n?: help\n");
-}
-
-int
-run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
-{
- if(argc > 1)
- {
- fprintf(stderr, "%s: too many arguments\n", argv[0]);
- return EXIT_FAILURE;
- }
-
- Ice::PropertiesPtr properties = communicator->getProperties();
- const char* proxyProperty = "Hello.Proxy";
- string proxy = properties->getProperty(proxyProperty);
- if(proxy.empty())
- {
- fprintf(stderr, "%s: property `%s' not set\n", argv[0], proxyProperty);
- return EXIT_FAILURE;
- }
-
- HelloPrx hello = HelloPrx::checkedCast(communicator->stringToProxy(proxy));
- if(!hello)
- {
-
- fprintf(stderr, "%s: invalid proxy\n", argv[0]);
- return EXIT_FAILURE;
- }
-
- menu();
-
- char c = EOF;
- do
- {
- try
- {
- printf("==> ");
- do
- {
- c = getchar();
- }
- while(c != EOF && c == '\n');
- if(c == 'h')
- {
- hello->sayHello();
- }
- else if(c == 'x')
- {
- // Nothing to do
- }
- else if(c == '?')
- {
- menu();
- }
- else
- {
- printf("unknown command `%c'\n", c);
- menu();
- }
- }
- catch(const Ice::Exception& ex)
- {
- fprintf(stderr, "%s\n", ex.toString().c_str());
- }
- }
- while(c != EOF && c != 'x');
-
- return EXIT_SUCCESS;
-}
-
int
main(int argc, char* argv[])
{
-
- int status;
+ int status = EXIT_SUCCESS;
Ice::CommunicatorPtr communicator;
try
{
- Ice::InitializationData initData;
- initData.properties = Ice::createProperties();
- initData.properties->load("config");
- communicator = Ice::initialize(argc, argv, initData);
- status = run(argc, argv, communicator);
+ communicator = Ice::initialize(argc, argv);
+ if(argc > 1)
+ {
+ fprintf(stderr, "%s: too many arguments\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+ HelloPrx hello = HelloPrx::checkedCast(communicator->stringToProxy("hello:tcp -p 10000"));
+ if(!hello)
+ {
+ fprintf(stderr, "%s: invalid proxy\n", argv[0]);
+ status = EXIT_FAILURE;
+ }
+ else
+ {
+ hello->sayHello();
+ }
}
catch(const Ice::Exception& ex)
{
fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
if(communicator)
{
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
- }
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ status = EXIT_FAILURE;
+ }
}
return status;