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 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; }