本文整理汇总了C++中ObjectPrx::ice_ping方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectPrx::ice_ping方法的具体用法?C++ ObjectPrx::ice_ping怎么用?C++ ObjectPrx::ice_ping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectPrx
的用法示例。
在下文中一共展示了ObjectPrx::ice_ping方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: communicator
int
CallbackClient::run(int argc, char* argv[])
{
ObjectPrx routerBase;
{
cout << "testing stringToProxy for router... " << flush;
routerBase = communicator()->stringToProxy("Glacier2/router:default -p 12347 -t 10000");
cout << "ok" << endl;
}
Glacier2::RouterPrx router;
{
cout << "testing checked cast for router... " << flush;
router = Glacier2::RouterPrx::checkedCast(routerBase);
test(router);
cout << "ok" << endl;
}
{
cout << "installing router with communicator... " << flush;
communicator()->setDefaultRouter(router);
cout << "ok" << endl;
}
{
cout << "getting the session timeout... " << flush;
Ice::Long timeout = router->getSessionTimeout();
test(timeout == 30);
cout << "ok" << endl;
}
ObjectPrx base;
{
cout << "testing stringToProxy for server object... " << flush;
base = communicator()->stringToProxy("c1/callback:tcp -p 12010 -t 10000");
cout << "ok" << endl;
}
{
cout << "trying to ping server before session creation... " << flush;
try
{
base->ice_ping();
test(false);
}
catch(const ConnectionLostException&)
{
cout << "ok" << endl;
}
}
Glacier2::SessionPrx session;
{
cout << "trying to create session with wrong password... " << flush;
try
{
session = router->createSession("userid", "xxx");
test(false);
}
catch(const Glacier2::PermissionDeniedException&)
{
cout << "ok" << endl;
}
}
{
cout << "trying to destroy non-existing session... " << flush;
try
{
router->destroySession();
test(false);
}
catch(const Glacier2::SessionNotExistException&)
{
cout << "ok" << endl;
}
}
{
cout << "creating session with correct password... " << flush;
session = router->createSession("userid", "abc123");
cout << "ok" << endl;
}
{
cout << "trying to create a second session... " << flush;
try
{
router->createSession("userid", "abc123");
test(false);
}
catch(const Glacier2::CannotCreateSessionException&)
{
cout << "ok" << endl;
}
}
//.........这里部分代码省略.........
示例2: createTestProperties
void
CallbackClient::run(int argc, char** argv)
{
Ice::PropertiesPtr properties = createTestProperties(argc, argv);
properties->setProperty("Ice.Warn.Connections", "0");
properties->setProperty("Ice.ThreadPool.Client.Serialize", "1");
Ice::CommunicatorHolder communicator = initialize(argc, argv, properties);
ObjectPrx routerBase = communicator->stringToProxy("Glacier2/router:" + getTestEndpoint(50));
Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(routerBase);
communicator->setDefaultRouter(router);
ObjectPrx base = communicator->stringToProxy("c/callback:" + getTestEndpoint());
Glacier2::SessionPrx session = router->createSession("userid", "abc123");
base->ice_ping();
CallbackPrx twoway = CallbackPrx::checkedCast(base);
CallbackPrx oneway = twoway->ice_oneway();
CallbackPrx batchOneway = twoway->ice_batchOneway();
communicator->getProperties()->setProperty("Ice.PrintAdapterReady", "0");
ObjectAdapterPtr adapter = communicator->createObjectAdapterWithRouter("CallbackReceiverAdapter", router);
adapter->activate();
string category = router->getCategoryForClient();
CallbackReceiverI* callbackReceiverImpl = new CallbackReceiverI;
ObjectPtr callbackReceiver = callbackReceiverImpl;
Identity callbackReceiverIdent;
callbackReceiverIdent.name = "callbackReceiver";
callbackReceiverIdent.category = category;
CallbackReceiverPrx twowayR =
CallbackReceiverPrx::uncheckedCast(adapter->add(callbackReceiver, callbackReceiverIdent));
CallbackReceiverPrx onewayR = twowayR->ice_oneway();
{
cout << "testing client request override... " << flush;
{
for(int i = 0; i < 5; i++)
{
oneway->initiateCallback(twowayR, 0);
oneway->initiateCallback(twowayR, 0);
callbackReceiverImpl->callbackOK(2, 0);
}
}
{
Ice::Context ctx;
ctx["_ovrd"] = "test";
for(int i = 0; i < 5; i++)
{
oneway->initiateCallback(twowayR, i, ctx);
oneway->initiateCallback(twowayR, i, ctx);
oneway->initiateCallback(twowayR, i, ctx);
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100));
test(callbackReceiverImpl->callbackOK(1, i) < 3);
}
}
cout << "ok" << endl;
}
{
cout << "testing server request override... " << flush;
Ice::Context ctx;
ctx["serverOvrd"] = "test";
for(int i = 0; i < 5; i++)
{
oneway->initiateCallback(onewayR, i, ctx);
oneway->initiateCallback(onewayR, i, ctx);
oneway->initiateCallback(onewayR, i, ctx);
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100));
test(callbackReceiverImpl->callbackOK(1, i) < 3);
}
oneway->initiateCallback(twowayR, 0);
test(callbackReceiverImpl->callbackOK(1, 0) == 0);
int count = 0;
int nRetry = 0;
do
{
callbackReceiverImpl->hold();
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallback(twowayR, 0);
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200 + nRetry * 200));
callbackReceiverImpl->activate();
test(callbackReceiverImpl->callbackOK(1, 0) == 0);
count = callbackReceiverImpl->callbackWithPayloadOK(0);
callbackReceiverImpl->callbackWithPayloadOK(count);
}
while(count == 10 && nRetry++ < 10);
//.........这里部分代码省略.........