本文整理汇总了C++中QueryResult::getBestConnectionSolution方法的典型用法代码示例。如果您正苦于以下问题:C++ QueryResult::getBestConnectionSolution方法的具体用法?C++ QueryResult::getBestConnectionSolution怎么用?C++ QueryResult::getBestConnectionSolution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryResult
的用法示例。
在下文中一共展示了QueryResult::getBestConnectionSolution方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: synchronize
int AutoConnectionEntry::synchronize (void)
{
if ((_ui32RemoteProxyID == 0) || (_connectorType == CT_UNDEF)) {
return -1;
}
_pConnectivitySolutions = _pConnectivitySolutions ? _pConnectivitySolutions : P_CONNECTION_MANAGER->findConnectivitySolutionsToProxyWithID (_ui32RemoteProxyID);
if (!_pConnectivitySolutions) {
return -2;
}
QueryResult query (_pConnectivitySolutions->getBestConnectionSolutionForConnectorType (_connectorType));
Connection *pActiveConnection = query.getActiveConnectionToRemoteProxy();
if (!pActiveConnection && !_pConnectivitySolutions->getRemoteProxyInfo().isRemoteProxyReachableFromLocalHost()) {
// It is impossible to open a connection to the remote NetProxy from the local host
return -3;
}
if (!pActiveConnection) {
Connector * const pConnector = P_CONNECTION_MANAGER->getConnectorForType (_connectorType);
if (!pConnector) {
// Critical error!
return -4;
}
pActiveConnection = pConnector->openNewConnectionToRemoteProxy (query, false);
if (!pActiveConnection && pConnector->isConnectingToRemoteAddr(query.getRemoteProxyServerAddress())) {
// Connection still establishing!
return 0;
}
query = _pConnectivitySolutions->getBestConnectionSolutionForConnectorType (_connectorType);
if (!(pActiveConnection = query.getActiveConnectionToRemoteProxy())) {
// Connection failed
return -5;
}
}
pActiveConnection->lock();
if (!pActiveConnection->isConnected()) {
// Unexpected case
pActiveConnection->unlock();
return -6;
}
if (_bSynchronized) {
// Nothing to do here
pActiveConnection->unlock();
return 0;
}
bool bReachable = _pConnectivitySolutions->getRemoteProxyInfo().isLocalProxyReachableFromRemote();
if (0 != pActiveConnection->openConnectionWithRemoteProxy (query.getBestConnectionSolution(), bReachable)) {
pActiveConnection->unlock();
_bSynchronized = false;
return -7;
}
pActiveConnection->unlock();
_bSynchronized = true;
return 0;
}