本文整理汇总了C++中ice::CommunicatorHolder::createObjectAdapterWithRouter方法的典型用法代码示例。如果您正苦于以下问题:C++ CommunicatorHolder::createObjectAdapterWithRouter方法的具体用法?C++ CommunicatorHolder::createObjectAdapterWithRouter怎么用?C++ CommunicatorHolder::createObjectAdapterWithRouter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ice::CommunicatorHolder
的用法示例。
在下文中一共展示了CommunicatorHolder::createObjectAdapterWithRouter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
//.........这里部分代码省略.........