本文整理汇总了C++中HelloPrx类的典型用法代码示例。如果您正苦于以下问题:C++ HelloPrx类的具体用法?C++ HelloPrx怎么用?C++ HelloPrx使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HelloPrx类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: communicator
int
HelloClient::run(int argc, char* argv[])
{
Ice::StringSeq args = Ice::argsToStringSeq(argc, argv);
args = communicator()->getProperties()->parseCommandLineOptions("Discover", args);
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("DiscoverReply");
DiscoverReplyIPtr replyI = new DiscoverReplyI;
DiscoverReplyPrx reply = DiscoverReplyPrx::uncheckedCast(adapter->addWithUUID(replyI));
adapter->activate();
DiscoverPrx discover = DiscoverPrx::uncheckedCast(
communicator()->propertyToProxy("Discover.Proxy")->ice_datagram());
discover->lookup(reply);
Ice::ObjectPrx base = replyI->waitReply(IceUtil::Time::seconds(2));
if(!base)
{
cerr << argv[0] << ": no replies" << endl;
return EXIT_FAILURE;
}
HelloPrx hello = HelloPrx::checkedCast(base);
if(!hello)
{
cerr << argv[0] << ": invalid reply" << endl;
return EXIT_FAILURE;
}
hello->sayHello();
return EXIT_SUCCESS;
}
示例2: run
int run(int argc, char* argv[]) {
ObjectPrx proxy = communicator()->stringToProxy(argv[1]);
HelloPrx hello = HelloPrx::checkedCast(proxy);
hello->puts("Hello, World!");
return 0;
}
示例3: appName
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;
}
示例4: callbackOnInterrupt
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;
}
示例5: callbackOnInterrupt
int
HelloClient::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();
//
// Get the hello proxy. We configure the proxy to not cache the
// server connection with the proxy and to disable the locator
// cache. With this configuration, the IceGrid locator will be
// queried for each invocation on the proxy and the invocation
// will be sent over the server connection matching the returned
// endpoints.
//
Ice::ObjectPrx obj = communicator()->stringToProxy("hello");
obj = obj->ice_connectionCached(false);
obj = obj->ice_locatorCacheTimeout(0);
HelloPrx hello = HelloPrx::checkedCast(obj);
if(!hello)
{
cerr << argv[0] << ": couldn't find a `::Demo::Hello' object." << endl;
return EXIT_FAILURE;
}
string s;
do
{
cout << "enter the number of iterations: ";
cin >> s;
int count = atoi(s.c_str());
cout << "enter the delay between each greetings (in ms): ";
cin >> s;
int delay = atoi(s.c_str());
if(delay < 0)
{
delay = 500; // 500 milli-seconds
}
for(int i = 0; i < count; i++)
{
cout << hello->getGreeting() << endl;
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(delay));
}
}
while(cin.good() && s != "x");
return EXIT_SUCCESS;
}
示例6: appName
int
HelloClient::run(int argc, char* argv[])
{
if(argc > 1)
{
cerr << appName() << ": too many arguments" << endl;
return EXIT_FAILURE;
}
HelloPrx hello = HelloPrx::uncheckedCast(communicator()->propertyToProxy("Hello.Proxy"));
if(!hello)
{
cerr << argv[0] << ": invalid or missing Hello.Proxy property" << endl;
return EXIT_FAILURE;
}
hello->sayHello();
return EXIT_SUCCESS;
}
示例7: main
int main(int argc, char* argv[]) {
int status = 0;
Ice::CommunicatorPtr ic;
try {
ic = Ice::initialize(argc, argv);
Ice::ObjectPrx base = ic->stringToProxy( "dodo:tcp -p 10002");
cout<<"server info: " << base << endl;
HelloPrx hp = HelloPrx::checkedCast(base);
if (hp)
hp->sayHello();
} catch (const Ice::Exception& ex) {
cerr << ex << endl;
status = 1;
} catch (const char* msg) {
cerr << msg << endl;
status = 1;
}
if (ic)
ic->destroy();
return status;
}
示例8: appName
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)
{
//.........这里部分代码省略.........
示例9: allTests
//.........这里部分代码省略.........
communicator->stringToProxy("[email protected]")->ice_locatorCacheTimeout(0)->ice_ping(); // No locator cache.
test(++count == locator->getRequestCount());
communicator->stringToProxy("[email protected]")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout.
test(count == locator->getRequestCount());
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1300));
communicator->stringToProxy("[email protected]")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout.
test(++count == locator->getRequestCount());
communicator->stringToProxy("test")->ice_locatorCacheTimeout(0)->ice_ping(); // No locator cache.
count += 2;
test(count == locator->getRequestCount());
communicator->stringToProxy("test")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout
test(count == locator->getRequestCount());
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1300));
communicator->stringToProxy("test")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout
count += 2;
test(count == locator->getRequestCount());
communicator->stringToProxy("[email protected]")->ice_locatorCacheTimeout(-1)->ice_ping();
test(count == locator->getRequestCount());
communicator->stringToProxy("test")->ice_locatorCacheTimeout(-1)->ice_ping();
test(count == locator->getRequestCount());
communicator->stringToProxy("[email protected]")->ice_ping();
test(count == locator->getRequestCount());
communicator->stringToProxy("test")->ice_ping();
test(count == locator->getRequestCount());
test(communicator->stringToProxy("test")->ice_locatorCacheTimeout(99)->ice_getLocatorCacheTimeout() == 99);
cout << "ok" << endl;
cout << "testing proxy from server... " << flush;
obj = TestIntfPrx::checkedCast(communicator->stringToProxy("[email protected]"));
HelloPrx hello = obj->getHello();
test(hello->ice_getAdapterId() == "TestAdapter");
hello->sayHello();
hello = obj->getReplicatedHello();
test(hello->ice_getAdapterId() == "ReplicatedAdapter");
hello->sayHello();
cout << "ok" << endl;
cout << "testing locator request queuing... " << flush;
hello = obj->getReplicatedHello()->ice_locatorCacheTimeout(0)->ice_connectionCached(false);
count = locator->getRequestCount();
hello->ice_ping();
test(++count == locator->getRequestCount());
int i;
list<Ice::AsyncResultPtr> results;
AMICallbackPtr cb = new AMICallback;
for(i = 0; i < 1000; i++)
{
Ice::AsyncResultPtr result = hello->begin_sayHello(
newCallback_Hello_sayHello(cb, &AMICallback::response1, &AMICallback::exception1));
results.push_back(result);
}
while(!results.empty())
{
Ice::AsyncResultPtr result = results.front();
results.pop_front();
result->waitForCompleted();
}
test(locator->getRequestCount() > count && locator->getRequestCount() < count + 999);
if(locator->getRequestCount() > count + 800)
{
cout << "queuing = " << locator->getRequestCount() - count;
示例10: run
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;
}
示例11: usage
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;
}
示例12: appName
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;
}
示例13: appName
int
HelloClient::run(int argc, char* argv[])
{
if(argc > 1)
{
cerr << appName() << ": too many arguments" << endl;
return EXIT_FAILURE;
}
int status = EXIT_SUCCESS;
IceGrid::RegistryPrx registry =
IceGrid::RegistryPrx::checkedCast(communicator()->stringToProxy("DemoIceGrid/Registry"));
if(!registry)
{
cerr << argv[0] << ": could not contact registry" << endl;
return EXIT_FAILURE;
}
IceGrid::SessionPrx session;
while(true)
{
cout << "This demo accepts any user-id / password combination.\n";
string id;
cout << "user id: " << flush;
getline(cin, id);
id = trim(id);
string password;
cout << "password: " << flush;
getline(cin, password);
password = trim(password);
try
{
session = registry->createSession(id, password);
break;
}
catch(const IceGrid::PermissionDeniedException& ex)
{
cout << "permission denied:\n" << ex.reason << endl;
}
}
SessionKeepAliveThreadPtr keepAlive = new SessionKeepAliveThread(session, registry->getSessionTimeout() / 2);
keepAlive->start();
try
{
HelloPrx hello = HelloPrx::checkedCast(session->allocateObjectById(communicator()->stringToIdentity("hello")));
menu();
char c;
do
{
try
{
cout << "==> ";
cin >> c;
if(c == 't')
{
hello->sayHello();
}
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');
}
catch(const IceGrid::AllocationException& ex)
{
cerr << argv[0] << ": could not allocate object: " << ex.reason << endl;
status = EXIT_FAILURE;
}
catch(const IceGrid::ObjectNotRegisteredException&)
{
cerr << argv[0] << ": object not registered with registry" << endl;
status = EXIT_FAILURE;
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
status = EXIT_FAILURE;
//.........这里部分代码省略.........
示例14: allTests
//.........这里部分代码省略.........
test(++count == locator->getRequestCount());
communicator->stringToProxy("[email protected]")->ice_locatorCacheTimeout(0)->ice_ping(); // No locator cache.
test(++count == locator->getRequestCount());
communicator->stringToProxy("[email protected]")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout.
test(count == locator->getRequestCount());
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1200));
communicator->stringToProxy("[email protected]")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout.
test(++count == locator->getRequestCount());
communicator->stringToProxy("test")->ice_locatorCacheTimeout(0)->ice_ping(); // No locator cache.
count += 2;
test(count == locator->getRequestCount());
communicator->stringToProxy("test")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout
test(count == locator->getRequestCount());
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1200));
communicator->stringToProxy("test")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout
count += 2;
test(count == locator->getRequestCount());
communicator->stringToProxy("[email protected]")->ice_locatorCacheTimeout(-1)->ice_ping();
test(count == locator->getRequestCount());
communicator->stringToProxy("test")->ice_locatorCacheTimeout(-1)->ice_ping();
test(count == locator->getRequestCount());
communicator->stringToProxy("[email protected]Adapter")->ice_ping();
test(count == locator->getRequestCount());
communicator->stringToProxy("test")->ice_ping();
test(count == locator->getRequestCount());
test(communicator->stringToProxy("test")->ice_locatorCacheTimeout(99)->ice_getLocatorCacheTimeout() == 99);
cout << "ok" << endl;
cout << "testing proxy from server... " << flush;
HelloPrx hello = obj->getHello();
test(hello->ice_getAdapterId() == "TestAdapter");
hello->sayHello();
hello = obj->getReplicatedHello();
test(hello->ice_getAdapterId() == "ReplicatedAdapter");
hello->sayHello();
cout << "ok" << endl;
cout << "testing proxy from server after shutdown... " << flush;
obj->shutdown();
manager->startServer();
hello->sayHello();
cout << "ok" << endl;
cout << "testing object migration... " << flush;
hello = HelloPrx::checkedCast(communicator->stringToProxy("hello"));
obj->migrateHello();
hello->sayHello();
obj->migrateHello();
hello->sayHello();
obj->migrateHello();
hello->sayHello();
cout << "ok" << endl;
cout << "shutdown server... " << flush;
obj->shutdown();
cout << "ok" << endl;
cout << "testing whether server is gone... " << flush;
try
{
obj2->ice_ping();
test(false);