mirror of
https://github.com/overte-org/overte.git
synced 2025-04-06 23:53:09 +02:00
Handle local address changes for servers
This commit is contained in:
parent
0804ffe5eb
commit
cfcea359b2
2 changed files with 7 additions and 1 deletions
|
@ -739,6 +739,10 @@ void DomainServer::setupNodeListAndAssignments() {
|
|||
|
||||
connect(nodeList.data(), &LimitedNodeList::nodeAdded, this, &DomainServer::nodeAdded);
|
||||
connect(nodeList.data(), &LimitedNodeList::nodeKilled, this, &DomainServer::nodeKilled);
|
||||
connect(nodeList.data(), &LimitedNodeList::localSockAddrChanged, this,
|
||||
[this](const HifiSockAddr& localSockAddr) {
|
||||
DependencyManager::get<LimitedNodeList>()->putLocalPortIntoSharedMemory(DOMAIN_SERVER_LOCAL_PORT_SMEM_KEY, this, localSockAddr.getPort());
|
||||
});
|
||||
|
||||
// register as the packet receiver for the types we want
|
||||
PacketReceiver& packetReceiver = nodeList->getPacketReceiver();
|
||||
|
|
|
@ -1237,16 +1237,18 @@ void LimitedNodeList::setLocalSocket(const HifiSockAddr& sockAddr) {
|
|||
|
||||
if (_localSockAddr.isNull()) {
|
||||
qCInfo(networking) << "Local socket is" << sockAddr;
|
||||
_localSockAddr = sockAddr;
|
||||
} else {
|
||||
qCInfo(networking) << "Local socket has changed from" << _localSockAddr << "to" << sockAddr;
|
||||
_localSockAddr = sockAddr;
|
||||
if (_hasTCPCheckedLocalSocket) { // Force a port change for NAT:
|
||||
reset();
|
||||
_nodeSocket.rebind(0);
|
||||
_localSockAddr.setPort(_nodeSocket.localPort());
|
||||
qCInfo(networking) << "Local port changed to" << _localSockAddr.getPort();
|
||||
}
|
||||
}
|
||||
|
||||
_localSockAddr = sockAddr;
|
||||
emit localSockAddrChanged(_localSockAddr);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue