int CallbackClient::run(int argc, char* argv[]) { // // Since this is an interactive demo we want the custom interrupt // callback to be called when the process is interrupted. // callbackOnInterrupt(); CallbackSenderPrx twoway = CallbackSenderPrx::checkedCast( communicator()->propertyToProxy("Callback.CallbackServer")-> ice_twoway()->ice_timeout(-1)->ice_secure(false)); if(!twoway) { cerr << appName() << ": invalid proxy" << endl; return EXIT_FAILURE; } CallbackSenderPrx oneway = CallbackSenderPrx::uncheckedCast(twoway->ice_oneway()); CallbackSenderPrx batchOneway = CallbackSenderPrx::uncheckedCast(twoway->ice_batchOneway()); CallbackSenderPrx datagram = CallbackSenderPrx::uncheckedCast(twoway->ice_datagram()); CallbackSenderPrx batchDatagram = CallbackSenderPrx::uncheckedCast(twoway->ice_batchDatagram()); Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Client"); adapter->add(new CallbackReceiverI, communicator()->stringToIdentity("callbackReceiver")); adapter->activate(); CallbackReceiverPrx twowayR = CallbackReceiverPrx::uncheckedCast( adapter->createProxy(communicator()->stringToIdentity("callbackReceiver"))); CallbackReceiverPrx onewayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_oneway()); CallbackReceiverPrx datagramR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_datagram()); bool secure = false; string secureStr = ""; menu(); char c; do { try { cout << "==> "; cin >> c; if(c == 't') { twoway->initiateCallback(twowayR); } else if(c == 'o') { oneway->initiateCallback(onewayR); } else if(c == 'O') { batchOneway->initiateCallback(onewayR); } else if(c == 'd') { if(secure) { cout << "secure datagrams are not supported" << endl; } else { datagram->initiateCallback(datagramR); } } else if(c == 'D') { if(secure) { cout << "secure datagrams are not supported" << endl; } else { batchDatagram->initiateCallback(datagramR); } } else if(c == 'f') { communicator()->flushBatchRequests(); } else if(c == 'S') { secure = !secure; secureStr = secure ? "s" : ""; twoway = CallbackSenderPrx::uncheckedCast(twoway->ice_secure(secure)); oneway = CallbackSenderPrx::uncheckedCast(oneway->ice_secure(secure)); batchOneway = CallbackSenderPrx::uncheckedCast(batchOneway->ice_secure(secure)); datagram = CallbackSenderPrx::uncheckedCast(datagram->ice_secure(secure)); batchDatagram = CallbackSenderPrx::uncheckedCast(batchDatagram->ice_secure(secure)); twowayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_secure(secure)); onewayR = CallbackReceiverPrx::uncheckedCast(onewayR->ice_secure(secure)); datagramR = CallbackReceiverPrx::uncheckedCast(datagramR->ice_secure(secure)); if(secure) { cout << "secure mode is now on" << endl; } else { cout << "secure mode is now off" << endl; } } else if(c == 's') { twoway->shutdown(); } else if(c == 'x') { // Nothing to do } else if(c == '?') { menu(); } else { cout << "unknown command `" << c << "'" << endl; menu(); } } catch(const Ice::Exception& ex) { cerr << ex << endl; } } while(cin.good() && c != 'x'); return EXIT_SUCCESS; }