本文整理汇总了C++中ice::ObjectPrxPtr类的典型用法代码示例。如果您正苦于以下问题:C++ ObjectPrxPtr类的具体用法?C++ ObjectPrxPtr怎么用?C++ ObjectPrxPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectPrxPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sync
vector<EndpointIPtr>
IceInternal::RouterInfo::setClientEndpoints(const Ice::ObjectPrxPtr& proxy)
{
IceUtil::Mutex::Lock sync(*this);
if(_clientEndpoints.empty())
{
if(!proxy)
{
//
// If getClientProxy() return nil, use router endpoints.
//
_clientEndpoints = _router->__reference()->getEndpoints();
}
else
{
Ice::ObjectPrxPtr clientProxy = proxy->ice_router(0); // The client proxy cannot be routed.
//
// In order to avoid creating a new connection to the router,
// we must use the same timeout as the already existing
// connection.
//
if(_router->ice_getConnection())
{
clientProxy = clientProxy->ice_timeout(_router->ice_getConnection()->timeout());
}
_clientEndpoints = clientProxy->__reference()->getEndpoints();
}
}
return _clientEndpoints;
}
示例2: ProxyOutgoingBase
ProxyFlushBatch::ProxyFlushBatch(const Ice::ObjectPrxPtr& proxy, const string& operation) :
ProxyOutgoingBase(proxy, ICE_ENUM(OperationMode, Normal))
{
checkSupportedProtocol(getCompatibleProtocol(proxy->__reference()->getProtocol()));
_observer.attach(proxy, operation, ::Ice::noExplicitContext);
_batchRequestNum = proxy->__getBatchRequestQueue()->swap(&_os);
}
示例3: request
void
BatchRequestQueue::finishBatchRequest(OutputStream* os, const Ice::ObjectPrxPtr& proxy, const std::string& operation)
{
//
// No need for synchronization, no other threads are supposed
// to modify the queue since we set _batchStreamInUse to true.
//
assert(_batchStreamInUse);
_batchStream.swap(*os);
try
{
_batchStreamCanFlush = true; // Allow flush to proceed even if the stream is marked in use.
if(_maxSize > 0 && _batchStream.b.size() >= _maxSize)
{
#ifdef ICE_CPP11_MAPPING
proxy->ice_flushBatchRequests_async();
#else
proxy->begin_ice_flushBatchRequests();
#endif
}
assert(_batchMarker < _batchStream.b.size());
if(_interceptor)
{
BatchRequestI request(*this, proxy, operation, static_cast<int>(_batchStream.b.size() - _batchMarker));
#ifdef ICE_CPP11_MAPPING
_interceptor(request, _batchRequestNum, static_cast<int>(_batchMarker));
#else
_interceptor->enqueue(request, _batchRequestNum, static_cast<int>(_batchMarker));
#endif
}
else
{
_batchMarker = _batchStream.b.size();
++_batchRequestNum;
}
Lock sync(*this);
_batchStream.resize(_batchMarker);
_batchStreamInUse = false;
_batchStreamCanFlush = false;
notifyAll();
}
catch(const std::exception&)
{
Lock sync(*this);
_batchStream.resize(_batchMarker);
_batchStreamInUse = false;
_batchStreamCanFlush = false;
notifyAll();
throw;
}
}
示例4: sync
Ice::ObjectPrxPtr
LocatorRegistryI::findObject(const Ice::Identity& id) const
{
Lock sync(*this);
if(id.name.empty())
{
return 0;
}
Ice::ObjectPrxPtr prx = _wellKnownProxy->ice_identity(id);
vector<string> adapterIds;
for(map<string, set<string> >::const_iterator p = _replicaGroups.begin(); p != _replicaGroups.end(); ++p)
{
try
{
prx->ice_adapterId(p->first)->ice_ping();
adapterIds.push_back(p->first);
}
catch(const Ice::Exception&)
{
// Ignore
}
}
if(adapterIds.empty())
{
for(map<string, Ice::ObjectPrxPtr>::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
{
try
{
prx->ice_adapterId(p->first)->ice_ping();
adapterIds.push_back(p->first);
}
catch(const Ice::Exception&)
{
// Ignore
}
}
}
if(adapterIds.empty())
{
return 0;
}
random_shuffle(adapterIds.begin(), adapterIds.end());
return prx->ice_adapterId(adapterIds[0]);
}
示例5: 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;
}
示例6: attach
IceInternal::InvocationObserver::InvocationObserver(const Ice::ObjectPrxPtr& proxy, const string& op, const Context& ctx)
{
const CommunicatorObserverPtr& obsv = proxy->__reference()->getInstance()->initializationData().observer;
if(!obsv)
{
return;
}
attach(obsv->getInvocationObserver(proxy, op, ctx));
}
示例7: test
ICE_DECLSPEC_EXPORT void
consume(const Ice::ObjectPtr& o, const Ice::ObjectPrxPtr& p)
{
cout << "testing dynamic cast across libraries... " << flush;
//
// Make sure dynamic cast works as expected
// and exception raised by a shared library can be caught by another
// shared library
//
Test::MyInterfacePtr servant = ICE_DYNAMIC_CAST(Test::MyInterface, o);
test(servant);
#ifdef ICE_CPP11_MAPPING
auto proxy = dynamic_pointer_cast<Test::MyInterfacePrx>(p);
#else
Test::MyInterfacePrx proxy = dynamic_cast<IceProxy::Test::MyInterface*>(p.get());
#endif
test(proxy);
proxy->op(false);
servant->op(false, Ice::emptyCurrent);
cout << "ok" << endl;
cout << "testing exceptions thrown across libraries... " << flush;
try
{
proxy->op(true);
}
catch(const Test::UserError&)
{
// expected
}
catch(...)
{
test(false);
}
try
{
servant->op(true, Ice::emptyCurrent);
}
catch(const Test::UserError&)
{
// expected
}
catch(...)
{
test(false);
}
cout << "ok" << endl;
}
示例8: OutgoingBase
ProxyOutgoingBase::ProxyOutgoingBase(const Ice::ObjectPrxPtr& proxy, OperationMode mode) :
OutgoingBase(proxy->__reference()->getInstance().get()),
_proxy(proxy),
_mode(mode),
_state(StateUnsent)
{
int invocationTimeout = _proxy->__reference()->getInvocationTimeout();
if(invocationTimeout > 0)
{
_invocationTimeoutDeadline = Time::now(Time::Monotonic) + Time::milliSeconds(invocationTimeout);
}
}
示例9: assert
bool
IceInternal::RouterInfo::addProxy(const Ice::ObjectPrxPtr& proxy, const AddProxyCallbackPtr& callback)
{
assert(proxy);
{
IceUtil::Mutex::Lock sync(*this);
if(_identities.find(proxy->ice_getIdentity()) != _identities.end())
{
//
// Only add the proxy to the router if it's not already in our local map.
//
return true;
}
}
Ice::ObjectProxySeq proxies;
proxies.push_back(proxy);
AddProxyCookiePtr cookie = new AddProxyCookie(callback, proxy);
#ifdef ICE_CPP11_MAPPING
RouterInfoPtr self = this;
_router->addProxies_async(proxies,
[self, cookie](const Ice::ObjectProxySeq& proxies)
{
self->addProxyResponse(proxies, cookie);
},
[self, cookie](exception_ptr e)
{
try
{
rethrow_exception(e);
}
catch(const Ice::Exception& ex)
{
self->addProxyException(ex, cookie);
}
});
#else
_router->begin_addProxies(proxies,
newCallback_Router_addProxies(this,
&RouterInfo::addProxyResponse,
&RouterInfo::addProxyException),
cookie);
#endif
return false;
}
示例10: 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());
//.........这里部分代码省略.........
示例11: catch
void
batchOneways(const Test::MyClassPrxPtr& p)
{
const Test::ByteS bs1(10 * 1024);
Test::MyClassPrxPtr batch = ICE_UNCHECKED_CAST(Test::MyClassPrx, p->ice_batchOneway());
batch->ice_flushBatchRequests(); // Empty flush
if(batch->ice_getConnection())
{
batch->ice_getConnection()->flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy));
}
batch->ice_getCommunicator()->flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy));
int i;
p->opByteSOnewayCallCount(); // Reset the call count
for(i = 0 ; i < 30 ; ++i)
{
try
{
batch->opByteSOneway(bs1);
}
catch(const Ice::LocalException& ex)
{
cerr << ex << endl;
test(false);
}
}
int count = 0;
while(count < 27) // 3 * 9 requests auto-flushed.
{
count += p->opByteSOnewayCallCount();
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10));
}
if(batch->ice_getConnection() &&
p->ice_getCommunicator()->getProperties()->getProperty("Ice.Default.Protocol") != "bt")
{
Test::MyClassPrxPtr batch1 = ICE_UNCHECKED_CAST(Test::MyClassPrx, p->ice_batchOneway());
Test::MyClassPrxPtr batch2 = ICE_UNCHECKED_CAST(Test::MyClassPrx, p->ice_batchOneway());
batch1->ice_ping();
batch2->ice_ping();
batch1->ice_flushBatchRequests();
batch1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
batch1->ice_ping();
batch2->ice_ping();
batch1->ice_getConnection();
batch2->ice_getConnection();
batch1->ice_ping();
batch1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
batch1->ice_ping();
batch2->ice_ping();
}
Ice::Identity identity;
identity.name = "invalid";
Ice::ObjectPrxPtr batch3 = batch->ice_identity(identity);
batch3->ice_ping();
batch3->ice_flushBatchRequests();
// Make sure that a bogus batch request doesn't cause troubles to other ones.
batch3->ice_ping();
batch->ice_ping();
batch->ice_flushBatchRequests();
batch->ice_ping();
if(batch->ice_getConnection() &&
p->ice_getCommunicator()->getProperties()->getProperty("Ice.Default.Protocol") != "bt")
{
Ice::InitializationData initData;
initData.properties = p->ice_getCommunicator()->getProperties()->clone();
BatchRequestInterceptorIPtr interceptor = ICE_MAKE_SHARED(BatchRequestInterceptorI);
#if defined(ICE_CPP11_MAPPING)
initData.batchRequestInterceptor = [=](const Ice::BatchRequest& request, int count, int size)
{
interceptor->enqueue(request, count, size);
};
#else
initData.batchRequestInterceptor = interceptor;
#endif
Ice::CommunicatorPtr ic = Ice::initialize(initData);
Test::MyClassPrxPtr batch =
ICE_UNCHECKED_CAST(Test::MyClassPrx, ic->stringToProxy(p->ice_toString()))->ice_batchOneway();
test(interceptor->count() == 0);
batch->ice_ping();
batch->ice_ping();
batch->ice_ping();
test(interceptor->count() == 0);
interceptor->enqueue(true);
batch->ice_ping();
batch->ice_ping();
batch->ice_ping();
//.........这里部分代码省略.........
示例12: out
void
ObjectAdapterI::updateLocatorRegistry(const IceInternal::LocatorInfoPtr& locatorInfo, const Ice::ObjectPrxPtr& proxy)
{
if(_id.empty() || !locatorInfo)
{
return; // Nothing to update.
}
LocatorRegistryPrxPtr locatorRegistry = locatorInfo->getLocatorRegistry();
if(!locatorRegistry)
{
return;
}
try
{
if(_replicaGroupId.empty())
{
locatorRegistry->setAdapterDirectProxy(_id, proxy);
}
else
{
locatorRegistry->setReplicatedAdapterDirectProxy(_id, _replicaGroupId, proxy);
}
}
catch(const AdapterNotFoundException&)
{
if(_instance->traceLevels()->location >= 1)
{
Trace out(_instance->initializationData().logger, _instance->traceLevels()->locationCat);
out << "couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n";
out << "the object adapter is not known to the locator registry";
}
throw NotRegisteredException(__FILE__, __LINE__, "object adapter", _id);
}
catch(const InvalidReplicaGroupIdException&)
{
if(_instance->traceLevels()->location >= 1)
{
Trace out(_instance->initializationData().logger, _instance->traceLevels()->locationCat);
out << "couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n";
out << "the replica group `" << _replicaGroupId << "' is not known to the locator registry";
}
throw NotRegisteredException(__FILE__, __LINE__, "replica group", _replicaGroupId);
}
catch(const AdapterAlreadyActiveException&)
{
if(_instance->traceLevels()->location >= 1)
{
Trace out(_instance->initializationData().logger, _instance->traceLevels()->locationCat);
out << "couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n";
out << "the object adapter endpoints are already set";
}
throw ObjectAdapterIdInUseException(__FILE__, __LINE__, _id);
}
catch(const ObjectAdapterDeactivatedException&)
{
// Expected if collocated call and OA is deactivated, ignore.
}
catch(const CommunicatorDestroyedException&)
{
// Ignore.
}
catch(const LocalException& ex)
{
if(_instance->traceLevels()->location >= 1)
{
Trace out(_instance->initializationData().logger, _instance->traceLevels()->locationCat);
out << "couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n" << ex;
}
throw; // TODO: Shall we raise a special exception instead of a non obvious local exception?
}
if(_instance->traceLevels()->location >= 1)
{
Trace out(_instance->initializationData().logger, _instance->traceLevels()->locationCat);
out << "updated object adapter `" + _id + "' endpoints with the locator registry\n";
out << "endpoints = ";
if(proxy)
{
EndpointSeq endpts = proxy ? proxy->ice_getEndpoints() : EndpointSeq();
ostringstream o;
transform(endpts.begin(), endpts.end(), ostream_iterator<string>(o, endpts.size() > 1 ? ":" : ""),
Ice::constMemFun(&Endpoint::toString));
out << o.str();
}
}
}
示例13: test
void
allTests(const Ice::CommunicatorPtr& communicator, const string& ref)
{
ServerManagerPrxPtr manager = ICE_CHECKED_CAST(ServerManagerPrx, communicator->stringToProxy(ref));
TestLocatorPrxPtr locator = ICE_UNCHECKED_CAST(TestLocatorPrx, communicator->getDefaultLocator());
test(manager);
TestLocatorRegistryPrxPtr registry = ICE_CHECKED_CAST(TestLocatorRegistryPrx, locator->getRegistry());
test(registry);
cout << "testing stringToProxy... " << flush;
Ice::ObjectPrxPtr base = communicator->stringToProxy("test @ TestAdapter");
Ice::ObjectPrxPtr base2 = communicator->stringToProxy("test @ TestAdapter");
Ice::ObjectPrxPtr base3 = communicator->stringToProxy("test");
Ice::ObjectPrxPtr base4 = communicator->stringToProxy("ServerManager");
Ice::ObjectPrxPtr base5 = communicator->stringToProxy("test2");
Ice::ObjectPrxPtr base6 = communicator->stringToProxy("test @ ReplicatedAdapter");
cout << "ok" << endl;
cout << "testing ice_locator and ice_getLocator... " << flush;
test(Ice::proxyIdentityEqual(base->ice_getLocator(), communicator->getDefaultLocator()));
Ice::LocatorPrxPtr anotherLocator = ICE_UNCHECKED_CAST(Ice::LocatorPrx, communicator->stringToProxy("anotherLocator"));
base = base->ice_locator(anotherLocator);
test(Ice::proxyIdentityEqual(base->ice_getLocator(), anotherLocator));
communicator->setDefaultLocator(ICE_NULLPTR);
base = communicator->stringToProxy("test @ TestAdapter");
test(!base->ice_getLocator());
base = base->ice_locator(anotherLocator);
test(Ice::proxyIdentityEqual(base->ice_getLocator(), anotherLocator));
communicator->setDefaultLocator(locator);
base = communicator->stringToProxy("test @ TestAdapter");
test(Ice::proxyIdentityEqual(base->ice_getLocator(), communicator->getDefaultLocator()));
//
// We also test ice_router/ice_getRouter (perhaps we should add a
// test/Ice/router test?)
//
test(!base->ice_getRouter());
Ice::RouterPrxPtr anotherRouter = ICE_UNCHECKED_CAST(Ice::RouterPrx, communicator->stringToProxy("anotherRouter"));
base = base->ice_router(anotherRouter);
test(Ice::proxyIdentityEqual(base->ice_getRouter(), anotherRouter));
Ice::RouterPrxPtr router = ICE_UNCHECKED_CAST(Ice::RouterPrx, communicator->stringToProxy("dummyrouter"));
communicator->setDefaultRouter(router);
base = communicator->stringToProxy("test @ TestAdapter");
test(Ice::proxyIdentityEqual(base->ice_getRouter(), communicator->getDefaultRouter()));
communicator->setDefaultRouter(0);
base = communicator->stringToProxy("test @ TestAdapter");
test(!base->ice_getRouter());
cout << "ok" << endl;
cout << "starting server... " << flush;
manager->startServer();
cout << "ok" << endl;
cout << "testing checked cast... " << flush;
TestIntfPrxPtr obj = ICE_CHECKED_CAST(TestIntfPrx, base);
test(obj);
TestIntfPrxPtr obj2 = ICE_CHECKED_CAST(TestIntfPrx, base2);
test(obj2);
TestIntfPrxPtr obj3 = ICE_CHECKED_CAST(TestIntfPrx, base3);
test(obj3);
ServerManagerPrxPtr obj4 = ICE_CHECKED_CAST(ServerManagerPrx, base4);
test(obj4);
TestIntfPrxPtr obj5 = ICE_CHECKED_CAST(TestIntfPrx, base5);
test(obj5);
TestIntfPrxPtr obj6 = ICE_CHECKED_CAST(TestIntfPrx, base6);
test(obj6);
cout << "ok" << endl;
cout << "testing [email protected] indirect proxy... " << flush;
obj->shutdown();
manager->startServer();
try
{
obj2->ice_ping();
}
catch(const Ice::LocalException& ex)
{
cerr << ex << endl;
test(false);
}
cout << "ok" << endl;
cout << "testing [email protected] indirect proxy... " << flush;
obj->shutdown();
manager->startServer();
try
{
obj6->ice_ping();
}
catch(const Ice::LocalException& ex)
{
cerr << ex << endl;
test(false);
}
cout << "ok" << endl;
cout << "testing identity indirect proxy... " << flush;
obj->shutdown();
manager->startServer();
//.........这里部分代码省略.........
示例14: getTestEndpoint
//.........这里部分代码省略.........
#if defined(_WIN32) && !defined(ICE_OS_WINRT)
OSVERSIONINFO ver;
ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
# if defined(_MSC_VER) && _MSC_VER >= 1800
# pragma warning (disable : 4996)
# endif
GetVersionEx(&ver);
# if defined(_MSC_VER) && _MSC_VER >= 1800
# pragma warning (default : 4996)
# endif
const bool dualStack = ver.dwMajorVersion >= 6; // Windows XP IPv6 doesn't support dual-stack
#else
const bool dualStack = true;
#endif
bool ipv6NotSupported = false;
for(vector<Ice::PropertiesPtr>::const_iterator p = serverProps.begin(); p != serverProps.end(); ++p)
{
Ice::InitializationData serverInitData;
serverInitData.properties = *p;
Ice::CommunicatorPtr serverCommunicator = Ice::initialize(serverInitData);
Ice::ObjectAdapterPtr oa;
try
{
oa = serverCommunicator->createObjectAdapter("Adapter");
oa->activate();
}
catch(const Ice::DNSException&)
{
serverCommunicator->destroy();
continue; // IP version not supported.
}
catch(const Ice::SocketException&)
{
if(*p == ipv6)
{
ipv6NotSupported = true;
}
serverCommunicator->destroy();
continue; // IP version not supported.
}
// Ensure the published endpoints are actually valid. On
// Fedora, binding to "localhost" with IPv6 only works but
// resolving localhost don't return the IPv6 adress.
Ice::ObjectPrxPtr prx = oa->createProxy(serverCommunicator->stringToIdentity("dummy"));
try
{
prx->ice_collocationOptimized(false)->ice_ping();
}
catch(const Ice::LocalException&)
{
serverCommunicator->destroy();
continue; // IP version not supported.
}
string strPrx = prx->ice_toString();
for(vector<Ice::PropertiesPtr>::const_iterator q = clientProps.begin(); q != clientProps.end(); ++q)
{
Ice::InitializationData clientInitData;
clientInitData.properties = *q;
Ice::CommunicatorHolder clientCommunicator = Ice::initialize(clientInitData);
Ice::ObjectPrxPtr prx = clientCommunicator->stringToProxy(strPrx);
try
{
prx->ice_ping();
test(false);
}
catch(const Ice::ObjectNotExistException&)
{
// Expected, no object registered.
}
catch(const Ice::DNSException&)
{
// Expected if no IPv4 or IPv6 address is
// associated to localhost or if trying to connect
// to an any endpoint with the wrong IP version,
// e.g.: resolving an IPv4 address when only IPv6
// is enabled fails with a DNS exception.
}
catch(const Ice::SocketException&)
{
test((*p == ipv4 && *q == ipv6) || (*p == ipv6 && *q == ipv4) ||
(*p == bothPreferIPv4 && *q == ipv6) || (*p == bothPreferIPv6 && *q == ipv4) ||
(*p == bothPreferIPv6 && *q == ipv6 && ipv6NotSupported) ||
(*p == anyipv4 && *q == ipv6) || (*p == anyipv6 && *q == ipv4) ||
(*p == anyboth && *q == ipv4 && !dualStack) ||
(*p == localipv4 && *q == ipv6) || (*p == localipv6 && *q == ipv4) ||
(*p == ipv6 && *q == bothPreferIPv4) || (*p == ipv6 && *q == bothPreferIPv6) ||
(*p == bothPreferIPv6 && *q == ipv6));
}
}
serverCommunicator->destroy();
}
cout << "ok" << endl;
}
com->shutdown();
}
示例15: is
void
allTests(Test::TestHelper* helper)
{
Ice::CommunicatorPtr communicator = helper->communicator();
cout << "testing proxy endpoint information... " << flush;
{
Ice::ObjectPrxPtr p1 =
communicator->stringToProxy("test -t:default -h tcphost -p 10000 -t 1200 -z --sourceAddress 10.10.10.10:"
"udp -h udphost -p 10001 --interface eth0 --ttl 5 --sourceAddress 10.10.10.10:"
"opaque -e 1.8 -t 100 -v ABCD");
Ice::EndpointSeq endps = p1->ice_getEndpoints();
Ice::EndpointInfoPtr info = endps[0]->getInfo();
Ice::TCPEndpointInfoPtr ipEndpoint = getTCPEndpointInfo(info);
test(ipEndpoint);
test(ipEndpoint->host == "tcphost");
test(ipEndpoint->port == 10000);
test(ipEndpoint->timeout == 1200);
#if !defined(ICE_OS_UWP)
test(ipEndpoint->sourceAddress == "10.10.10.10");
#endif
test(ipEndpoint->compress);
test(!ipEndpoint->datagram());
test((ipEndpoint->type() == Ice::TCPEndpointType && !ipEndpoint->secure()) ||
(ipEndpoint->type() == Ice::SSLEndpointType && ipEndpoint->secure()) ||
(ipEndpoint->type() == Ice::WSEndpointType && !ipEndpoint->secure()) ||
(ipEndpoint->type() == Ice::WSSEndpointType && ipEndpoint->secure()));
test((ipEndpoint->type() == Ice::TCPEndpointType && ICE_DYNAMIC_CAST(Ice::TCPEndpointInfo, info)) ||
(ipEndpoint->type() == Ice::SSLEndpointType && ICE_DYNAMIC_CAST(IceSSL::EndpointInfo, info)) ||
(ipEndpoint->type() == Ice::WSEndpointType && ICE_DYNAMIC_CAST(Ice::WSEndpointInfo, info)) ||
(ipEndpoint->type() == Ice::WSSEndpointType && ICE_DYNAMIC_CAST(Ice::WSEndpointInfo, info)));
Ice::UDPEndpointInfoPtr udpEndpoint = ICE_DYNAMIC_CAST(Ice::UDPEndpointInfo, endps[1]->getInfo());
test(udpEndpoint);
test(udpEndpoint->host == "udphost");
test(udpEndpoint->port == 10001);
#if !defined(ICE_OS_UWP)
test(udpEndpoint->sourceAddress == "10.10.10.10");
#endif
test(udpEndpoint->mcastInterface == "eth0");
test(udpEndpoint->mcastTtl == 5);
test(udpEndpoint->timeout == -1);
test(!udpEndpoint->compress);
test(!udpEndpoint->secure());
test(udpEndpoint->datagram());
test(udpEndpoint->type() == Ice::UDPEndpointType);
Ice::OpaqueEndpointInfoPtr opaqueEndpoint = ICE_DYNAMIC_CAST(Ice::OpaqueEndpointInfo, endps[2]->getInfo());
test(opaqueEndpoint);
Ice::EncodingVersion rev;
rev.major = 1;
rev.minor = 8;
test(opaqueEndpoint->rawEncoding == rev);
}
cout << "ok" << endl;
string defaultHost = communicator->getProperties()->getProperty("Ice.Default.Host");
#ifdef ICE_OS_UWP
bool uwp = true;
#else
bool uwp = false;
#endif
if(!uwp || (communicator->getProperties()->getProperty("Ice.Default.Protocol") != "ssl" &&
communicator->getProperties()->getProperty("Ice.Default.Protocol") != "wss"))
{
cout << "test object adapter endpoint information... " << flush;
{
communicator->getProperties()->setProperty("TestAdapter.Endpoints",
"default -h 127.0.0.1 -t 15000:udp -h 127.0.0.1");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
Ice::EndpointSeq endpoints = adapter->getEndpoints();
test(endpoints.size() == 2);
Ice::EndpointSeq publishedEndpoints = adapter->getPublishedEndpoints();
test(endpoints == publishedEndpoints);
Ice::TCPEndpointInfoPtr ipEndpoint = getTCPEndpointInfo(endpoints[0]->getInfo());
test(ipEndpoint);
test(ipEndpoint->type() == Ice::TCPEndpointType || ipEndpoint->type() == Ice::SSLEndpointType ||
ipEndpoint->type() == Ice::WSEndpointType || ipEndpoint->type() == Ice::WSSEndpointType);
test(ipEndpoint->host == "127.0.0.1");
test(ipEndpoint->port > 0);
test(ipEndpoint->timeout == 15000);
Ice::UDPEndpointInfoPtr udpEndpoint = ICE_DYNAMIC_CAST(Ice::UDPEndpointInfo, endpoints[1]->getInfo());
test(udpEndpoint);
test(udpEndpoint->host == "127.0.0.1");
test(udpEndpoint->datagram());
test(udpEndpoint->port > 0);
endpoints.pop_back();
test(endpoints.size() == 1);
adapter->setPublishedEndpoints(endpoints);
publishedEndpoints = adapter->getPublishedEndpoints();
test(endpoints == publishedEndpoints);
adapter->destroy();
//.........这里部分代码省略.........