handle domain-server local port changes once connected

This commit is contained in:
Stephen Birarda 2015-03-31 16:11:41 -07:00
parent e73e74336e
commit 740438d08d
4 changed files with 19 additions and 11 deletions

View file

@ -33,8 +33,7 @@ AddressManager::AddressManager() :
_rootPlaceName(), _rootPlaceName(),
_rootPlaceID(), _rootPlaceID(),
_positionGetter(NULL), _positionGetter(NULL),
_orientationGetter(NULL), _orientationGetter(NULL)
_localDSPortSharedMem(NULL)
{ {
connect(qApp, &QCoreApplication::aboutToQuit, this, &AddressManager::storeCurrentAddress); connect(qApp, &QCoreApplication::aboutToQuit, this, &AddressManager::storeCurrentAddress);
} }
@ -331,13 +330,6 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString) {
quint16 domainPort = DEFAULT_DOMAIN_SERVER_PORT; quint16 domainPort = DEFAULT_DOMAIN_SERVER_PORT;
if (domainHostname == "localhost") {
auto nodeList = DependencyManager::get<NodeList>();
nodeList->getLocalServerPortFromSharedMemory(DOMAIN_SERVER_LOCAL_PORT_SMEM_KEY,
_localDSPortSharedMem,
domainPort);
}
if (!hostnameRegex.cap(2).isEmpty()) { if (!hostnameRegex.cap(2).isEmpty()) {
domainPort = (qint16) hostnameRegex.cap(2).toInt(); domainPort = (qint16) hostnameRegex.cap(2).toInt();
} }

View file

@ -95,8 +95,6 @@ private:
QUuid _rootPlaceID; QUuid _rootPlaceID;
PositionGetter _positionGetter; PositionGetter _positionGetter;
OrientationGetter _orientationGetter; OrientationGetter _orientationGetter;
QSharedMemory* _localDSPortSharedMem; // memory shared with domain server
}; };
#endif // hifi_AddressManager_h #endif // hifi_AddressManager_h

View file

@ -47,6 +47,7 @@ public:
void setSockAddr(const HifiSockAddr& sockAddr, const QString& hostname); void setSockAddr(const HifiSockAddr& sockAddr, const QString& hostname);
unsigned short getPort() const { return _sockAddr.getPort(); } unsigned short getPort() const { return _sockAddr.getPort(); }
void setPort(quint16 port) { _sockAddr.setPort(port); }
const QUuid& getAssignmentUUID() const { return _assignmentUUID; } const QUuid& getAssignmentUUID() const { return _assignmentUUID; }
void setAssignmentUUID(const QUuid& assignmentUUID) { _assignmentUUID = assignmentUUID; } void setAssignmentUUID(const QUuid& assignmentUUID) { _assignmentUUID = assignmentUUID; }

View file

@ -277,6 +277,23 @@ void NodeList::sendDomainServerCheckIn() {
if (!_domainHandler.isConnected()) { if (!_domainHandler.isConnected()) {
qDebug() << "Sending connect request to domain-server at" << _domainHandler.getHostname(); qDebug() << "Sending connect request to domain-server at" << _domainHandler.getHostname();
// is this our localhost domain-server?
// if so we need to make sure we have an up-to-date local port in case it restarted
if (_domainHandler.getSockAddr().getAddress() == QHostAddress::LocalHost
|| _domainHandler.getHostname() == "localhost") {
static QSharedMemory* localDSPortSharedMem = NULL;
quint16 domainPort = DEFAULT_DOMAIN_SERVER_PORT;
getLocalServerPortFromSharedMemory(DOMAIN_SERVER_LOCAL_PORT_SMEM_KEY,
localDSPortSharedMem,
domainPort);
qDebug() << "Local domain-server port read from shared memory (or default) is" << domainPort;
_domainHandler.setPort(domainPort);
}
} }
// construct the DS check in packet // construct the DS check in packet