int PluginClient::run(int argc, char* argv[]) { if(argc > 1) { cerr << appName() << ": too many arguments" << endl; return EXIT_FAILURE; } HelloPrx hello = HelloPrx::checkedCast(communicator()->propertyToProxy("Hello.Proxy")); if(!hello) { cerr << argv[0] << ": invalid proxy" << endl; return EXIT_FAILURE; } menu(); char c; do { try { cout << "==> "; cin >> c; if(c == 't') { hello->sayHello(); } else if(c == 's') { hello->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; }
int AsyncClient::run(int argc, char* argv[]) { callbackOnInterrupt(); HelloPrx hello = HelloPrx::checkedCast(communicator()->propertyToProxy("Hello.Proxy")); if(!hello) { cerr << argv[0] << ": invalid proxy" << endl; return EXIT_FAILURE; } menu(); char c; do { try { cout << "==> "; cin >> c; if(c == 'i') { hello->sayHello(0); } else if(c == 'd') { hello->sayHello_async(new AMI_Hello_sayHelloI, 5000); } else if(c == 's') { hello->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; }
int HelloClient::run(int argc, char* argv[]) { if(argc > 1) { cerr << appName() << ": too many arguments" << endl; return EXIT_FAILURE; } HelloPrx twoway = HelloPrx::checkedCast( communicator()->propertyToProxy("Hello.Proxy")->ice_twoway()->ice_timeout(-1)->ice_secure(false)); if(!twoway) { cerr << argv[0] << ": invalid proxy" << endl; return EXIT_FAILURE; } HelloPrx oneway = twoway->ice_oneway(); HelloPrx batchOneway = twoway->ice_batchOneway(); HelloPrx datagram = twoway->ice_datagram(); HelloPrx batchDatagram = twoway->ice_batchDatagram(); bool secure = false; int timeout = -1; int delay = 0; menu(); char c; do { try { cout << "==> "; cin >> c; if(c == 't') { twoway->sayHello(delay); } else if(c == 'o') { oneway->sayHello(delay); } else if(c == 'O') { batchOneway->sayHello(delay); } else if(c == 'd') { if(secure) { cout << "secure datagrams are not supported" << endl; } else { datagram->sayHello(delay); } } else if(c == 'D') { if(secure) { cout << "secure datagrams are not supported" << endl; } else { batchDatagram->sayHello(delay); } } else if(c == 'f') { communicator()->flushBatchRequests(); } else if(c == 'T') { if(timeout == -1) { timeout = 2000; } else { timeout = -1; } twoway = twoway->ice_timeout(timeout); oneway = oneway->ice_timeout(timeout); batchOneway = batchOneway->ice_timeout(timeout); if(timeout == -1) { cout << "timeout is now switched off" << endl; } else { cout << "timeout is now set to 2000ms" << endl; } } else if(c == 'P') { if(delay == 0) { delay = 2500; } else { delay = 0; } if(delay == 0) { cout << "server delay is now deactivated" << endl; } else { cout << "server delay is now set to 2500ms" << endl; } } else if(c == 'S') { secure = !secure; twoway = twoway->ice_secure(secure); oneway = oneway->ice_secure(secure); batchOneway = batchOneway->ice_secure(secure); datagram = datagram->ice_secure(secure); batchDatagram = batchDatagram->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; }
int run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { if(argc > 1) { fprintf(stderr, "%s: too many arguments", argv[0]); return EXIT_FAILURE; } HelloPrx hello = HelloPrx::checkedCast(communicator->propertyToProxy("Hello.Proxy")); if(!hello) { fprintf(stderr, "%s: invalid proxy\n", argv[0]); return EXIT_FAILURE; } menu(); char c = EOF; do { try { printf("==> "); fflush(stdout); do { c = getchar(); } while(c != EOF && c == '\n'); if(c == 'i') { hello->sayHello(0); } else if(c == 'd') { hello->sayHello_async(new AMI_Hello_sayHelloI, 5000); } else if(c == 's') { hello->shutdown(); } 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 HelloClient::run(int argc, char* argv[]) { if(argc > 2) { usage(); return EXIT_FAILURE; } bool addContext = false; if(argc == 2) { if(string(argv[1]) == "--context") { addContext = true; } else { usage(); return EXIT_FAILURE; } } // // Add the context entry that allows the client to use the locator // if(addContext) { Ice::LocatorPrx locator = communicator()->getDefaultLocator(); Ice::Context ctx; ctx["SECRET"] = "LetMeIn"; communicator()->setDefaultLocator(locator->ice_context(ctx)); } // // Now we try to connect to the object with the `hello' identity. // HelloPrx hello = HelloPrx::checkedCast(communicator()->stringToProxy("hello")); if(!hello) { cerr << argv[0] << ": couldn't find a `hello' object." << endl; return EXIT_FAILURE; } menu(); char c = 'x'; do { try { cout << "==> "; cin >> c; if(c == 't') { hello->sayHello(); } else if(c == 't') { hello->sayHello(); } else if(c == 's') { hello->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; }
int HelloClient::run(int argc, char* argv[]) { if(argc > 1) { cerr << appName() << ": too many arguments" << endl; return EXIT_FAILURE; } // // First we try to connect to the object with the `hello' // identity. If it's not registered with the registry, we // search for an object with the ::Demo::Hello type. // HelloPrx hello; try { hello = HelloPrx::checkedCast(communicator()->stringToProxy("hello")); } catch(const Ice::NotRegisteredException&) { IceGrid::QueryPrx query = IceGrid::QueryPrx::checkedCast(communicator()->stringToProxy("DemoIceGrid/Query")); hello = HelloPrx::checkedCast(query->findObjectByType("::Demo::Hello")); } if(!hello) { cerr << argv[0] << ": couldn't find a `::Demo::Hello' object." << endl; return EXIT_FAILURE; } menu(); char c; do { try { cout << "==> "; cin >> c; if(c == 't') { hello->sayHello(); } else if(c == 's') { hello->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; }