mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 22:50:54 +02:00
handle ICE requirement in address manager response
This commit is contained in:
parent
11659401ee
commit
262054d0eb
7 changed files with 97 additions and 65 deletions
|
@ -67,6 +67,10 @@ void IceServer::processDatagrams() {
|
|||
// check if this node also included a UUID that they would like to connect to
|
||||
QUuid connectRequestUUID;
|
||||
hearbeatStream >> connectRequestUUID;
|
||||
|
||||
if (!connectRequestUUID.isNull()) {
|
||||
qDebug() << "Peer wants to connect to peer with ID" << uuidStringWithoutCurlyBraces(connectRequestUUID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -299,10 +299,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
|
||||
AddressManager& addressManager = AddressManager::getInstance();
|
||||
|
||||
// connect to the domainChangeRequired signal on AddressManager
|
||||
connect(&addressManager, &AddressManager::possibleDomainChangeRequired,
|
||||
// handle domain change signals from AddressManager
|
||||
connect(&addressManager, &AddressManager::possibleDomainChangeRequiredToHostname,
|
||||
this, &Application::changeDomainHostname);
|
||||
|
||||
connect(&addressManager, &AddressManager::possibleDomainChangeRequiredViaICEForID,
|
||||
&domainHandler, &DomainHandler::setIceServerHostnameAndID);
|
||||
|
||||
_settings = new QSettings(this);
|
||||
_numChangedSettings = 0;
|
||||
|
||||
|
|
|
@ -118,9 +118,21 @@ void AddressManager::handleAPIResponse(const QJsonObject &jsonObject) {
|
|||
QJsonObject domainObject = dataObject[ADDRESS_API_DOMAIN_KEY].toObject();
|
||||
|
||||
const QString DOMAIN_NETWORK_ADDRESS_KEY = "network_address";
|
||||
const QString DOMAIN_ICE_SERVER_ADDRESS_KEY = "ice_server_address";
|
||||
|
||||
if (domainObject.contains(DOMAIN_NETWORK_ADDRESS_KEY)) {
|
||||
QString domainHostname = domainObject[DOMAIN_NETWORK_ADDRESS_KEY].toString();
|
||||
|
||||
emit possibleDomainChangeRequired(domainHostname);
|
||||
emit possibleDomainChangeRequiredToHostname(domainHostname);
|
||||
} else {
|
||||
QString iceServerAddress = domainObject[DOMAIN_ICE_SERVER_ADDRESS_KEY].toString();
|
||||
|
||||
const QString DOMAIN_ID_KEY = "id";
|
||||
QString domainIDString = domainObject[DOMAIN_ID_KEY].toString();
|
||||
QUuid domainID(domainIDString);
|
||||
|
||||
emit possibleDomainChangeRequiredViaICEForID(iceServerAddress, domainID);
|
||||
}
|
||||
|
||||
// take the path that came back
|
||||
const QString LOCATION_KEY = "location";
|
||||
|
@ -182,7 +194,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString) {
|
|||
QRegExp hostnameRegex(HOSTNAME_REGEX_STRING, Qt::CaseInsensitive);
|
||||
|
||||
if (hostnameRegex.indexIn(lookupString) != -1) {
|
||||
emit possibleDomainChangeRequired(hostnameRegex.cap(0));
|
||||
emit possibleDomainChangeRequiredToHostname(hostnameRegex.cap(0));
|
||||
emit lookupResultsFinished();
|
||||
return true;
|
||||
}
|
||||
|
@ -190,7 +202,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString) {
|
|||
QRegExp ipAddressRegex(IP_ADDRESS_REGEX_STRING);
|
||||
|
||||
if (ipAddressRegex.indexIn(lookupString) != -1) {
|
||||
emit possibleDomainChangeRequired(ipAddressRegex.cap(0));
|
||||
emit possibleDomainChangeRequiredToHostname(ipAddressRegex.cap(0));
|
||||
emit lookupResultsFinished();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,8 @@ signals:
|
|||
void lookupResultsFinished();
|
||||
void lookupResultIsOffline();
|
||||
void lookupResultIsNotFound();
|
||||
void possibleDomainChangeRequired(const QString& newHostname);
|
||||
void possibleDomainChangeRequiredToHostname(const QString& newHostname);
|
||||
void possibleDomainChangeRequiredViaICEForID(const QString& iceServerHostname, const QUuid& domainID);
|
||||
void locationChangeRequired(const glm::vec3& newPosition,
|
||||
bool hasOrientationChange, const glm::quat& newOrientation,
|
||||
bool shouldFaceLocation);
|
||||
|
|
|
@ -25,7 +25,7 @@ DomainHandler::DomainHandler(QObject* parent) :
|
|||
_uuid(),
|
||||
_sockAddr(HifiSockAddr(QHostAddress::Null, DEFAULT_DOMAIN_SERVER_PORT)),
|
||||
_assignmentUUID(),
|
||||
_requiresICE(true),
|
||||
_iceServerSockAddr(),
|
||||
_isConnected(false),
|
||||
_handshakeTimer(NULL),
|
||||
_settingsObject(),
|
||||
|
@ -36,7 +36,7 @@ DomainHandler::DomainHandler(QObject* parent) :
|
|||
|
||||
void DomainHandler::clearConnectionInfo() {
|
||||
_uuid = QUuid();
|
||||
_requiresICE = true;
|
||||
_iceServerSockAddr = HifiSockAddr();
|
||||
_isConnected = false;
|
||||
emit disconnectedFromDomain();
|
||||
|
||||
|
@ -125,6 +125,19 @@ void DomainHandler::setHostname(const QString& hostname) {
|
|||
}
|
||||
}
|
||||
|
||||
void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname, const QUuid& id) {
|
||||
if (id != _uuid) {
|
||||
// re-set the domain info to connect to new domain
|
||||
hardReset();
|
||||
|
||||
_uuid = id;
|
||||
_iceServerSockAddr = HifiSockAddr(iceServerHostname, ICE_SERVER_DEFAULT_PORT);
|
||||
|
||||
qDebug() << "Domain ID changed to" << uuidStringWithoutCurlyBraces(_uuid)
|
||||
<< "- ICE required via ice server at" << iceServerHostname;
|
||||
}
|
||||
}
|
||||
|
||||
void DomainHandler::completedHostnameLookup(const QHostInfo& hostInfo) {
|
||||
for (int i = 0; i < hostInfo.addresses().size(); i++) {
|
||||
if (hostInfo.addresses()[i].protocol() == QAbstractSocket::IPv4Protocol) {
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
const QUuid& getAssignmentUUID() const { return _assignmentUUID; }
|
||||
void setAssignmentUUID(const QUuid& assignmentUUID) { _assignmentUUID = assignmentUUID; }
|
||||
|
||||
bool requiresICE() const { return _requiresICE; }
|
||||
bool requiresICE() const { return !_iceServerSockAddr.isNull(); }
|
||||
|
||||
bool isConnected() const { return _isConnected; }
|
||||
void setIsConnected(bool isConnected);
|
||||
|
@ -68,6 +68,7 @@ public:
|
|||
void softReset();
|
||||
public slots:
|
||||
void setHostname(const QString& hostname);
|
||||
void setIceServerHostnameAndID(const QString& iceServerHostname, const QUuid& id);
|
||||
|
||||
private slots:
|
||||
void completedHostnameLookup(const QHostInfo& hostInfo);
|
||||
|
@ -87,7 +88,7 @@ private:
|
|||
QString _hostname;
|
||||
HifiSockAddr _sockAddr;
|
||||
QUuid _assignmentUUID;
|
||||
bool _requiresICE;
|
||||
HifiSockAddr _iceServerSockAddr;
|
||||
bool _isConnected;
|
||||
QTimer* _handshakeTimer;
|
||||
QJsonObject _settingsObject;
|
||||
|
|
|
@ -242,11 +242,10 @@ void NodeList::sendDomainServerCheckIn() {
|
|||
// we don't know our public socket and we need to send it to the domain server
|
||||
// send a STUN request to figure it out
|
||||
sendSTUNRequest();
|
||||
} else if (!_domainHandler.isConnected() && _domainHandler.requiresICE()) {
|
||||
sendICERequestForDomainConnection();
|
||||
} else if (!_domainHandler.getIP().isNull()) {
|
||||
|
||||
if (!_domainHandler.isConnected() && _domainHandler.requiresICE()) {
|
||||
sendICERequestForDomainConnection();
|
||||
} else {
|
||||
bool isUsingDTLS = false;
|
||||
|
||||
PacketType domainPacketType = !_domainHandler.isConnected()
|
||||
|
@ -300,7 +299,6 @@ void NodeList::sendDomainServerCheckIn() {
|
|||
_numNoReplyDomainCheckIns++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeList::sendICERequestForDomainConnection() {
|
||||
|
||||
|
|
Loading…
Reference in a new issue