diff options
author | Marc Laukien <marc@zeroc.com> | 2004-08-26 13:00:19 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2004-08-26 13:00:19 +0000 |
commit | 6eee09cec2a6d656dfbf314b246807a9426e4f8c (patch) | |
tree | b175559f170ab1392b280e57e4d26dc436268153 /cpp | |
parent | single server-side OA (diff) | |
download | ice-6eee09cec2a6d656dfbf314b246807a9426e4f8c.tar.bz2 ice-6eee09cec2a6d656dfbf314b246807a9426e4f8c.tar.xz ice-6eee09cec2a6d656dfbf314b246807a9426e4f8c.zip |
more glacier2
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/demo/Glacier2/callback/CallbackI.cpp | 18 | ||||
-rw-r--r-- | cpp/demo/Glacier2/callback/Client.cpp | 36 | ||||
-rw-r--r-- | cpp/demo/Glacier2/callback/passwords | 0 | ||||
-rw-r--r-- | cpp/demo/Ice/callback/CallbackI.cpp | 18 | ||||
-rw-r--r-- | cpp/src/Glacier2/RouterI.cpp | 33 |
5 files changed, 83 insertions, 22 deletions
diff --git a/cpp/demo/Glacier2/callback/CallbackI.cpp b/cpp/demo/Glacier2/callback/CallbackI.cpp index 81ca02eb44b..9946c2bd0b9 100644 --- a/cpp/demo/Glacier2/callback/CallbackI.cpp +++ b/cpp/demo/Glacier2/callback/CallbackI.cpp @@ -23,12 +23,26 @@ void CallbackI::initiateCallback(const CallbackReceiverPrx& proxy, const Current& current) { cout << "initiating callback to: " << current.adapter->getCommunicator()->proxyToString(proxy) << endl; - proxy->callback(current.ctx); + try + { + proxy->callback(current.ctx); + } + catch(const Exception& ex) + { + cout << ex << endl; + } } void CallbackI::shutdown(const Ice::Current& c) { cout << "Shutting down..." << endl; - c.adapter->getCommunicator()->shutdown(); + try + { + c.adapter->getCommunicator()->shutdown(); + } + catch(const Exception& ex) + { + cout << ex << endl; + } } diff --git a/cpp/demo/Glacier2/callback/Client.cpp b/cpp/demo/Glacier2/callback/Client.cpp index 47013ce10bc..0a0fc40fce1 100644 --- a/cpp/demo/Glacier2/callback/Client.cpp +++ b/cpp/demo/Glacier2/callback/Client.cpp @@ -38,6 +38,7 @@ menu() "O: invoke callback as batch oneway\n" "f: flush all batch requests\n" "v: set/reset override context field\n" + "F: set/reset fake category\n" "s: shutdown server\n" "x: exit\n" "?: help\n"; @@ -83,6 +84,14 @@ CallbackClient::run(int argc, char* argv[]) } } + string category = router->getServerProxy()->ice_getIdentity().category; + Identity callbackReceiverIdent; + callbackReceiverIdent.name = "callbackReceiver"; + callbackReceiverIdent.category = category; + Identity callbackReceiverFakeIdent; + callbackReceiverFakeIdent.name = "callbackReceiver"; + callbackReceiverFakeIdent.category = "fake"; + PropertiesPtr properties = communicator()->getProperties(); const char* proxyProperty = "Callback.Client.Callback"; std::string proxy = properties->getProperty(proxyProperty); @@ -96,19 +105,17 @@ CallbackClient::run(int argc, char* argv[]) CallbackPrx twoway = CallbackPrx::checkedCast(base); CallbackPrx oneway = CallbackPrx::uncheckedCast(twoway->ice_oneway()); CallbackPrx batchOneway = CallbackPrx::uncheckedCast(twoway->ice_batchOneway()); - CallbackPrx datagram = CallbackPrx::uncheckedCast(twoway->ice_datagram()); - CallbackPrx batchDatagram = CallbackPrx::uncheckedCast(twoway->ice_batchDatagram()); ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Client"); - adapter->add(new CallbackReceiverI, stringToIdentity("callbackReceiver")); + adapter->add(new CallbackReceiverI, callbackReceiverIdent); + adapter->add(new CallbackReceiverI, callbackReceiverFakeIdent); // Should never be called for the fake identity. adapter->activate(); - CallbackReceiverPrx twowayR = CallbackReceiverPrx::uncheckedCast( - adapter->createProxy(stringToIdentity("callbackReceiver"))); + CallbackReceiverPrx twowayR = CallbackReceiverPrx::uncheckedCast(adapter->createProxy(callbackReceiverIdent)); CallbackReceiverPrx onewayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_oneway()); - CallbackReceiverPrx datagramR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_datagram()); string override; + bool fake = false; menu(); @@ -166,6 +173,23 @@ CallbackClient::run(int argc, char* argv[]) cout << "override context field is empty" << endl; } } + else if(c == 'F') + { + fake = !fake; + + if(fake) + { + twowayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_newIdentity(callbackReceiverFakeIdent)); + onewayR = CallbackReceiverPrx::uncheckedCast(onewayR->ice_newIdentity(callbackReceiverFakeIdent)); + } + else + { + twowayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_newIdentity(callbackReceiverIdent)); + onewayR = CallbackReceiverPrx::uncheckedCast(onewayR->ice_newIdentity(callbackReceiverIdent)); + } + + cout << "callback receiver identity: " << identityToString(twowayR->ice_getIdentity()) << endl; + } else if(c == 's') { twoway->shutdown(); diff --git a/cpp/demo/Glacier2/callback/passwords b/cpp/demo/Glacier2/callback/passwords new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/cpp/demo/Glacier2/callback/passwords diff --git a/cpp/demo/Ice/callback/CallbackI.cpp b/cpp/demo/Ice/callback/CallbackI.cpp index 1e2fac27351..e8cd9053ab8 100644 --- a/cpp/demo/Ice/callback/CallbackI.cpp +++ b/cpp/demo/Ice/callback/CallbackI.cpp @@ -23,12 +23,26 @@ void CallbackI::initiateCallback(const CallbackReceiverPrx& proxy, const Current& current) { cout << "initiating callback" << endl; - proxy->callback(current.ctx); + try + { + proxy->callback(current.ctx); + } + catch(const Exception& ex) + { + cout << ex << endl; + } } void CallbackI::shutdown(const Ice::Current& c) { cout << "Shutting down..." << endl; - c.adapter->getCommunicator()->shutdown(); + try + { + c.adapter->getCommunicator()->shutdown(); + } + catch(const Exception& ex) + { + cout << ex << endl; + } } diff --git a/cpp/src/Glacier2/RouterI.cpp b/cpp/src/Glacier2/RouterI.cpp index c6d16731175..7162786f317 100644 --- a/cpp/src/Glacier2/RouterI.cpp +++ b/cpp/src/Glacier2/RouterI.cpp @@ -53,21 +53,30 @@ Glacier2::RouterI::RouterI(const ObjectAdapterPtr& clientAdapter, _clientProxy(clientAdapter->createProxy(stringToIdentity("dummy"))), _clientBlobject(new ClientBlobject(_communicator, _routingTable, "")) { - if(serverAdapter) + try { - ObjectPrx& serverProxy = const_cast<ObjectPrx&>(_serverProxy); - Identity ident; - ident.category.resize(20); - for(string::iterator p = ident.category.begin(); p != ident.category.end(); ++p) + if(serverAdapter) { - *p = static_cast<char>(33 + rand() % (127-33)); // We use ASCII 33-126 (from ! to ~, w/o space). + ObjectPrx& serverProxy = const_cast<ObjectPrx&>(_serverProxy); + Identity ident; + ident.name = "dummy"; + ident.category.resize(20); + for(string::iterator p = ident.category.begin(); p != ident.category.end(); ++p) + { + *p = static_cast<char>(33 + rand() % (127-33)); // We use ASCII 33-126 (from ! to ~, w/o space). + } + serverProxy = serverAdapter->createProxy(ident); + + ServerBlobjectPtr& serverBlobject = const_cast<ServerBlobjectPtr&>(_serverBlobject); + serverBlobject = new ServerBlobject(_communicator, transport); + serverAdapter->addServantLocator(new RouterLocator(serverBlobject), ident.category); + serverAdapter->activate(); } - serverProxy = serverAdapter->createProxy(ident); - - ServerBlobjectPtr& serverBlobject = const_cast<ServerBlobjectPtr&>(_serverBlobject); - serverBlobject = new ServerBlobject(_communicator, transport); - serverAdapter->addServantLocator(new RouterLocator(serverBlobject), ident.category); - serverAdapter->activate(); + } + catch(...) + { + destroy(); + throw; } } |