本文整理汇总了C++中ice::ObjectPrxPtr::ice_getConnection方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectPrxPtr::ice_getConnection方法的具体用法?C++ ObjectPrxPtr::ice_getConnection怎么用?C++ ObjectPrxPtr::ice_getConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ice::ObjectPrxPtr
的用法示例。
在下文中一共展示了ObjectPrxPtr::ice_getConnection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: allTests
int
run(int, char**, const Ice::CommunicatorPtr& communicator)
{
communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0));
communicator->getProperties()->setProperty("TestAdapter.AdapterId", "test");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
Ice::ObjectPrxPtr prx = adapter->add(ICE_MAKE_SHARED(MyDerivedClassI), Ice::stringToIdentity("test"));
//adapter->activate(); // Don't activate OA to ensure collocation is used.
test(!prx->ice_getConnection());
Test::MyClassPrxPtr allTests(const Ice::CommunicatorPtr&);
allTests(communicator);
return EXIT_SUCCESS;
}
示例2: is
//.........这里部分代码省略.........
ostringstream portStr;
portStr << port;
communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -h * -p " + portStr.str());
communicator->getProperties()->setProperty("TestAdapter.PublishedEndpoints", helper->getTestEndpoint(1));
adapter = communicator->createObjectAdapter("TestAdapter");
endpoints = adapter->getEndpoints();
test(endpoints.size() >= 1);
publishedEndpoints = adapter->getPublishedEndpoints();
test(publishedEndpoints.size() == 1);
for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
ipEndpoint = getTCPEndpointInfo((*p)->getInfo());
test(ipEndpoint->port == port);
}
ipEndpoint = getTCPEndpointInfo(publishedEndpoints[0]->getInfo());
test(ipEndpoint->host == helper->getTestHost());
test(ipEndpoint->port == port);
adapter->destroy();
}
cout << "ok" << endl;
}
string endpoints = helper->getTestEndpoint() + ":" + helper->getTestEndpoint("udp") + " -c";
int port = helper->getTestPort();
Ice::ObjectPrxPtr base = communicator->stringToProxy("test:" + endpoints);
TestIntfPrxPtr testIntf = ICE_CHECKED_CAST(TestIntfPrx, base);
cout << "test connection endpoint information... " << flush;
{
Ice::EndpointInfoPtr info = base->ice_getConnection()->getEndpoint()->getInfo();
Ice::TCPEndpointInfoPtr tcpinfo = getTCPEndpointInfo(info);
test(tcpinfo->port == port);
test(!tcpinfo->compress);
test(tcpinfo->host == defaultHost);
ostringstream os;
Ice::Context ctx = testIntf->getEndpointInfoAsContext();
test(ctx["host"] == tcpinfo->host);
test(ctx["compress"] == "false");
istringstream is(ctx["port"]);
int portCtx;
is >> portCtx;
test(portCtx > 0);
info = base->ice_datagram()->ice_getConnection()->getEndpoint()->getInfo();
Ice::UDPEndpointInfoPtr udp = ICE_DYNAMIC_CAST(Ice::UDPEndpointInfo, info);
test(udp);
test(udp->port == portCtx);
test(udp->host == defaultHost);
}
cout << "ok" << endl;
cout << "testing connection information... " << flush;
{
Ice::ConnectionPtr connection = base->ice_getConnection();
connection->setBufferSize(1024, 2048);
Ice::TCPConnectionInfoPtr info = getTCPConnectionInfo(connection->getInfo());
test(info);
test(!info->incoming);
test(info->adapterName.empty());
示例3: seq
TimeoutPrxPtr
allTests(const Ice::CommunicatorPtr& communicator)
{
string sref = "timeout:" + getTestEndpoint(communicator, 0);
Ice::ObjectPrxPtr obj = communicator->stringToProxy(sref);
test(obj);
TimeoutPrxPtr timeout = ICE_CHECKED_CAST(TimeoutPrx, obj);
test(timeout);
cout << "testing connect timeout... " << flush;
{
//
// Expect ConnectTimeoutException.
//
TimeoutPrxPtr to = ICE_UNCHECKED_CAST(TimeoutPrx, obj->ice_timeout(100));
timeout->holdAdapter(500);
try
{
to->op();
test(false);
}
catch(const Ice::ConnectTimeoutException&)
{
// Expected.
}
}
{
//
// Expect success.
//
timeout->op(); // Ensure adapter is active.
TimeoutPrxPtr to = ICE_UNCHECKED_CAST(TimeoutPrx, obj->ice_timeout(1000));
timeout->holdAdapter(500);
try
{
to->op();
}
catch(const Ice::ConnectTimeoutException&)
{
test(false);
}
}
cout << "ok" << endl;
// The sequence needs to be large enough to fill the write/recv buffers
ByteSeq seq(2000000);
cout << "testing connection timeout... " << flush;
{
//
// Expect TimeoutException.
//
TimeoutPrxPtr to = ICE_UNCHECKED_CAST(TimeoutPrx, obj->ice_timeout(100));
timeout->holdAdapter(500);
try
{
to->sendData(seq);
test(false);
}
catch(const Ice::TimeoutException&)
{
// Expected.
}
}
{
//
// Expect success.
//
timeout->op(); // Ensure adapter is active.
TimeoutPrxPtr to = ICE_UNCHECKED_CAST(TimeoutPrx, obj->ice_timeout(1000));
timeout->holdAdapter(500);
try
{
ByteSeq seq(1000000);
to->sendData(seq);
}
catch(const Ice::TimeoutException&)
{
test(false);
}
}
cout << "ok" << endl;
cout << "testing invocation timeout... " << flush;
{
Ice::ConnectionPtr connection = obj->ice_getConnection();
TimeoutPrxPtr to = ICE_UNCHECKED_CAST(TimeoutPrx, obj->ice_invocationTimeout(100));
test(connection == to->ice_getConnection());
try
{
to->sleep(750);
test(false);
}
catch(const Ice::InvocationTimeoutException&)
{
}
obj->ice_ping();
to = ICE_CHECKED_CAST(TimeoutPrx, obj->ice_invocationTimeout(500));
test(connection == to->ice_getConnection());
//.........这里部分代码省略.........