mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 16:23:17 +02:00
separate ICE ID and domain ID for reconnections to moved domains
This commit is contained in:
parent
cbc505e71a
commit
5203113b41
4 changed files with 17 additions and 8 deletions
|
@ -3462,9 +3462,9 @@ void Application::updateWindowTitle(){
|
||||||
void Application::updateLocationInServer() {
|
void Application::updateLocationInServer() {
|
||||||
|
|
||||||
AccountManager& accountManager = AccountManager::getInstance();
|
AccountManager& accountManager = AccountManager::getInstance();
|
||||||
const QUuid& domainUUID = NodeList::getInstance()->getDomainHandler().getUUID();
|
DomainHandler& domainHandler = NodeList::getInstance()->getDomainHandler();
|
||||||
|
|
||||||
if (accountManager.isLoggedIn() && !domainUUID.isNull()) {
|
if (accountManager.isLoggedIn() && domainHandler.isConnected() && !domainHandler.getUUID().isNull()) {
|
||||||
|
|
||||||
// construct a QJsonObject given the user's current address information
|
// construct a QJsonObject given the user's current address information
|
||||||
QJsonObject rootObject;
|
QJsonObject rootObject;
|
||||||
|
@ -3478,7 +3478,7 @@ void Application::updateLocationInServer() {
|
||||||
const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id";
|
const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id";
|
||||||
|
|
||||||
locationObject.insert(PATH_KEY_IN_LOCATION, pathString);
|
locationObject.insert(PATH_KEY_IN_LOCATION, pathString);
|
||||||
locationObject.insert(DOMAIN_ID_KEY_IN_LOCATION, domainUUID.toString());
|
locationObject.insert(DOMAIN_ID_KEY_IN_LOCATION, domainHandler.getUUID().toString());
|
||||||
|
|
||||||
rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject);
|
rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject);
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ DomainHandler::DomainHandler(QObject* parent) :
|
||||||
_uuid(),
|
_uuid(),
|
||||||
_sockAddr(HifiSockAddr(QHostAddress::Null, DEFAULT_DOMAIN_SERVER_PORT)),
|
_sockAddr(HifiSockAddr(QHostAddress::Null, DEFAULT_DOMAIN_SERVER_PORT)),
|
||||||
_assignmentUUID(),
|
_assignmentUUID(),
|
||||||
|
_iceDomainID(),
|
||||||
_iceClientID(),
|
_iceClientID(),
|
||||||
_iceServerSockAddr(),
|
_iceServerSockAddr(),
|
||||||
_icePeer(),
|
_icePeer(),
|
||||||
|
@ -39,9 +40,13 @@ DomainHandler::DomainHandler(QObject* parent) :
|
||||||
void DomainHandler::clearConnectionInfo() {
|
void DomainHandler::clearConnectionInfo() {
|
||||||
_uuid = QUuid();
|
_uuid = QUuid();
|
||||||
|
|
||||||
_iceServerSockAddr = HifiSockAddr();
|
|
||||||
_icePeer = NetworkPeer();
|
_icePeer = NetworkPeer();
|
||||||
|
|
||||||
|
if (requiresICE()) {
|
||||||
|
// if we connected to this domain with ICE, re-set the socket so we reconnect through the ice-server
|
||||||
|
_sockAddr.setAddress(QHostAddress::Null);
|
||||||
|
}
|
||||||
|
|
||||||
_isConnected = false;
|
_isConnected = false;
|
||||||
|
|
||||||
emit disconnectedFromDomain();
|
emit disconnectedFromDomain();
|
||||||
|
@ -65,6 +70,7 @@ void DomainHandler::softReset() {
|
||||||
|
|
||||||
void DomainHandler::hardReset() {
|
void DomainHandler::hardReset() {
|
||||||
softReset();
|
softReset();
|
||||||
|
_iceDomainID = QUuid();
|
||||||
_hostname = QString();
|
_hostname = QString();
|
||||||
_sockAddr.setAddress(QHostAddress::Null);
|
_sockAddr.setAddress(QHostAddress::Null);
|
||||||
}
|
}
|
||||||
|
@ -136,7 +142,7 @@ void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname,
|
||||||
// re-set the domain info to connect to new domain
|
// re-set the domain info to connect to new domain
|
||||||
hardReset();
|
hardReset();
|
||||||
|
|
||||||
setUUID(id);
|
_iceDomainID = id;
|
||||||
_iceServerSockAddr = HifiSockAddr(iceServerHostname, ICE_SERVER_DEFAULT_PORT);
|
_iceServerSockAddr = HifiSockAddr(iceServerHostname, ICE_SERVER_DEFAULT_PORT);
|
||||||
|
|
||||||
// refresh our ICE client UUID to something new
|
// refresh our ICE client UUID to something new
|
||||||
|
@ -265,7 +271,7 @@ void DomainHandler::processICEResponsePacket(const QByteArray& icePacket) {
|
||||||
NetworkPeer packetPeer;
|
NetworkPeer packetPeer;
|
||||||
iceResponseStream >> packetPeer;
|
iceResponseStream >> packetPeer;
|
||||||
|
|
||||||
if (packetPeer.getUUID() != _uuid) {
|
if (packetPeer.getUUID() != _iceDomainID) {
|
||||||
qDebug() << "Received a network peer with ID that does not match current domain. Will not attempt connection.";
|
qDebug() << "Received a network peer with ID that does not match current domain. Will not attempt connection.";
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Received network peer object for domain -" << packetPeer;
|
qDebug() << "Received network peer object for domain -" << packetPeer;
|
||||||
|
|
|
@ -55,6 +55,8 @@ public:
|
||||||
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; }
|
||||||
|
|
||||||
|
const QUuid& getICEDomainID() const { return _iceDomainID; }
|
||||||
|
|
||||||
const QUuid& getICEClientID() const { return _iceClientID; }
|
const QUuid& getICEClientID() const { return _iceClientID; }
|
||||||
|
|
||||||
bool requiresICE() const { return !_iceServerSockAddr.isNull(); }
|
bool requiresICE() const { return !_iceServerSockAddr.isNull(); }
|
||||||
|
@ -97,6 +99,7 @@ private:
|
||||||
QString _hostname;
|
QString _hostname;
|
||||||
HifiSockAddr _sockAddr;
|
HifiSockAddr _sockAddr;
|
||||||
QUuid _assignmentUUID;
|
QUuid _assignmentUUID;
|
||||||
|
QUuid _iceDomainID;
|
||||||
QUuid _iceClientID;
|
QUuid _iceClientID;
|
||||||
HifiSockAddr _iceServerSockAddr;
|
HifiSockAddr _iceServerSockAddr;
|
||||||
NetworkPeer _icePeer;
|
NetworkPeer _icePeer;
|
||||||
|
|
|
@ -342,10 +342,10 @@ void NodeList::handleICEConnectionToDomainServer() {
|
||||||
|
|
||||||
LimitedNodeList::sendHeartbeatToIceServer(_domainHandler.getICEServerSockAddr(),
|
LimitedNodeList::sendHeartbeatToIceServer(_domainHandler.getICEServerSockAddr(),
|
||||||
_domainHandler.getICEClientID(),
|
_domainHandler.getICEClientID(),
|
||||||
_domainHandler.getUUID());
|
_domainHandler.getICEDomainID());
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Sending ping packets to establish connectivity with domain-server with ID"
|
qDebug() << "Sending ping packets to establish connectivity with domain-server with ID"
|
||||||
<< uuidStringWithoutCurlyBraces(_domainHandler.getUUID());
|
<< uuidStringWithoutCurlyBraces(_domainHandler.getICEDomainID());
|
||||||
|
|
||||||
// send the ping packet to the local and public sockets for this nodfe
|
// send the ping packet to the local and public sockets for this nodfe
|
||||||
QByteArray localPingPacket = constructPingPacket(PingType::Local, false, _domainHandler.getICEClientID());
|
QByteArray localPingPacket = constructPingPacket(PingType::Local, false, _domainHandler.getICEClientID());
|
||||||
|
|
Loading…
Reference in a new issue