本文整理汇总了C++中ice::ConnectionPtr::setACM方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionPtr::setACM方法的具体用法?C++ ConnectionPtr::setACM怎么用?C++ ConnectionPtr::setACM使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ice::ConnectionPtr
的用法示例。
在下文中一共展示了ConnectionPtr::setACM方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void
SessionHelperI::connected(const Glacier2::RouterPrxPtr& router, const Glacier2::SessionPrxPtr& session)
{
//
// Remote invocation should be done without acquiring a mutex lock.
//
assert(router);
Ice::ConnectionPtr conn = router->ice_getCachedConnection();
string category = router->getCategoryForClient();
Ice::Int acmTimeout = 0;
try
{
acmTimeout = router->getACMTimeout();
}
catch(const Ice::OperationNotExistException&)
{
}
if(acmTimeout <= 0)
{
acmTimeout = static_cast<Ice::Int>(router->getSessionTimeout());
}
//
// We create the callback object adapter here because createObjectAdapter internally
// makes synchronous RPCs to the router. We can't create the OA on-demand when the
// client calls objectAdapter() or addWithUUID() because they can be called from the
// GUI thread.
//
if(_useCallbacks)
{
_adapter = _communicator->createObjectAdapterWithRouter("", router);
_adapter->activate();
}
bool destroy;
{
IceUtil::Mutex::Lock sync(_mutex);
_router = router;
destroy = _destroy;
if(!_destroy)
{
//
// Cache the category.
//
_category = category;
//
// Assign the session after _destroy is checked.
//
_session = session;
_connected = true;
if(acmTimeout > 0)
{
Ice::ConnectionPtr connection = _router->ice_getCachedConnection();
assert(connection);
connection->setACM(acmTimeout, IceUtil::None, Ice::HeartbeatAlways);
#ifdef ICE_CPP11_MAPPING
connection->setCloseCallback([self = shared_from_this()](Ice::ConnectionPtr)
{
self->destroy();
});
#else
connection->setCloseCallback(ICE_MAKE_SHARED(CloseCallbackI, shared_from_this()));
#endif
}
}
}
if(destroy)
{
//
// connected() is only called from the ConnectThread so it is ok to
// call destroyInternal here.
//
destroyInternal(new Disconnected(shared_from_this(), _callback));
}
else
{
dispatchCallback(new Connected(_callback, shared_from_this()), conn);
}
}
示例2: out
bool
Glacier2::Application::doMain(Ice::StringSeq& args, const Ice::InitializationData& initData, int& status)
{
//
// Reset internal state variables from Ice.Application. The
// remainder are reset at the end of this method.
//
IceInternal::Application::_callbackInProgress = false;
IceInternal::Application::_destroyed = false;
IceInternal::Application::_interrupted = false;
bool restart = false;
status = 0;
try
{
IceInternal::Application::_communicator = Ice::initialize(args, initData);
_router = Glacier2::RouterPrx::uncheckedCast(communicator()->getDefaultRouter());
if(!_router)
{
Error out(getProcessLogger());
out << IceInternal::Application::_appName << ": no glacier2 router configured";
status = 1;
}
else
{
//
// The default is to destroy when a signal is received.
//
if(IceInternal::Application::_signalPolicy == Ice::HandleSignals)
{
destroyOnInterrupt();
}
// If createSession throws, we're done.
try
{
_session = createSession();
_createdSession = true;
}
catch(const Ice::LocalException& ex)
{
Error out(getProcessLogger());
out << IceInternal::Application::_appName << ": " << ex;
status = 1;
}
if(_createdSession)
{
Ice::Int acmTimeout = 0;
try
{
acmTimeout = _router->getACMTimeout();
}
catch(const Ice::OperationNotExistException&)
{
}
if(acmTimeout <= 0)
{
acmTimeout = static_cast<Ice::Int>(_router->getSessionTimeout());
}
if(acmTimeout > 0)
{
Ice::ConnectionPtr connection = _router->ice_getCachedConnection();
assert(connection);
connection->setACM(acmTimeout, IceUtil::None, Ice::HeartbeatAlways);
connection->setCallback(new ConnectionCallbackI(this));
}
_category = _router->getCategoryForClient();
IceUtilInternal::ArgVector a(args);
status = runWithSession(a.argc, a.argv);
}
}
}
// We want to restart on those exceptions which indicate a
// break down in communications, but not those exceptions that
// indicate a programming logic error (ie: marshal, protocol
// failure, etc).
catch(const RestartSessionException&)
{
restart = true;
}
catch(const Ice::ConnectionRefusedException& ex)
{
Error out(getProcessLogger());
out << IceInternal::Application::_appName << ": " << ex;
restart = true;
}
catch(const Ice::ConnectionLostException& ex)
{
Error out(getProcessLogger());
out << IceInternal::Application::_appName << ": " << ex;
restart = true;
}
catch(const Ice::UnknownLocalException& ex)
{
Error out(getProcessLogger());
//.........这里部分代码省略.........