mirror of
https://github.com/overte-org/overte.git
synced 2025-07-26 08:15:21 +02:00
final fixes for path query from DS
This commit is contained in:
parent
7330e5255d
commit
332601b91c
9 changed files with 153 additions and 91 deletions
|
@ -2255,8 +2255,8 @@ void DomainServer::respondToPathQuery(const QByteArray& receivedPacket, const Hi
|
|||
qDebug() << "Sending a viewpoint response for path query" << pathQuery << "-" << viewpointUTF8;
|
||||
|
||||
// send off the packet - see if we can associate this outbound data to a particular node
|
||||
SharedNodePointer matchingNode = nodeList->sendingNodeForPacket(receivedPacket);
|
||||
nodeList->writeUnverifiedDatagram(pathResponsePacket, matchingNode, senderSockAddr);
|
||||
// TODO: does this senderSockAddr always work for a punched DS client?
|
||||
nodeList->writeUnverifiedDatagram(pathResponsePacket, senderSockAddr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,6 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl) {
|
|||
// wasn't an address - lookup the place name
|
||||
// we may have a path that defines a relative viewpoint - pass that through the lookup so we can go to it after
|
||||
attemptPlaceNameLookup(lookupUrl.host(), lookupUrl.path());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,10 +252,13 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
|
|||
qCDebug(networking) << "Received a location path that was could not be handled as a viewpoint -"
|
||||
<< returnedPath;
|
||||
}
|
||||
} else {
|
||||
// we didn't override the path or get one back - ask the DS for the viewpoint of its index path
|
||||
// which we will jump to if it exists
|
||||
emit pathChangeRequired(INDEX_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
qCDebug(networking) << "Received an address manager API response with no domain key. Cannot parse.";
|
||||
qCDebug(networking) << locationMap;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
const QString HIFI_URL_SCHEME = "hifi";
|
||||
const QString DEFAULT_HIFI_ADDRESS = "hifi://entry";
|
||||
const QString INDEX_PATH = "/";
|
||||
|
||||
typedef const glm::vec3& (*PositionGetter)();
|
||||
typedef glm::quat (*OrientationGetter)();
|
||||
|
|
|
@ -46,7 +46,7 @@ void DomainHandler::clearConnectionInfo() {
|
|||
|
||||
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);
|
||||
_sockAddr.clear();
|
||||
}
|
||||
|
||||
setIsConnected(false);
|
||||
|
@ -70,7 +70,10 @@ void DomainHandler::hardReset() {
|
|||
_iceDomainID = QUuid();
|
||||
_iceServerSockAddr = HifiSockAddr();
|
||||
_hostname = QString();
|
||||
_sockAddr.setAddress(QHostAddress::Null);
|
||||
_sockAddr.clear();
|
||||
|
||||
// clear any pending path we may have wanted to ask the previous DS about
|
||||
_pendingPath.clear();
|
||||
}
|
||||
|
||||
void DomainHandler::setSockAddr(const HifiSockAddr& sockAddr, const QString& hostname) {
|
||||
|
@ -142,19 +145,25 @@ void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname,
|
|||
void DomainHandler::activateICELocalSocket() {
|
||||
_sockAddr = _icePeer.getLocalSocket();
|
||||
_hostname = _sockAddr.getAddress().toString();
|
||||
emit completedSocketDiscovery();
|
||||
}
|
||||
|
||||
void DomainHandler::activateICEPublicSocket() {
|
||||
_sockAddr = _icePeer.getPublicSocket();
|
||||
_hostname = _sockAddr.getAddress().toString();
|
||||
emit completedSocketDiscovery();
|
||||
}
|
||||
|
||||
void DomainHandler::completedHostnameLookup(const QHostInfo& hostInfo) {
|
||||
for (int i = 0; i < hostInfo.addresses().size(); i++) {
|
||||
if (hostInfo.addresses()[i].protocol() == QAbstractSocket::IPv4Protocol) {
|
||||
_sockAddr.setAddress(hostInfo.addresses()[i]);
|
||||
|
||||
qCDebug(networking, "DS at %s is at %s", _hostname.toLocal8Bit().constData(),
|
||||
_sockAddr.getAddress().toString().toLocal8Bit().constData());
|
||||
|
||||
emit completedSocketDiscovery();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,6 +72,12 @@ public:
|
|||
void parseDTLSRequirementPacket(const QByteArray& dtlsRequirementPacket);
|
||||
void processICEResponsePacket(const QByteArray& icePacket);
|
||||
|
||||
void setPendingPath(const QString& pendingPath) { _pendingPath = pendingPath; }
|
||||
const QString& getPendingPath() { return _pendingPath; }
|
||||
void clearPendingPath() { _pendingPath.clear(); }
|
||||
|
||||
bool isSocketKnown() const { return !_sockAddr.getAddress().isNull(); }
|
||||
|
||||
void softReset();
|
||||
public slots:
|
||||
void setHostnameAndPort(const QString& hostname, quint16 port = DEFAULT_DOMAIN_SERVER_PORT);
|
||||
|
@ -82,8 +88,14 @@ private slots:
|
|||
void settingsRequestFinished();
|
||||
signals:
|
||||
void hostnameChanged(const QString& hostname);
|
||||
|
||||
// NOTE: the emission of completedSocketDiscovery does not mean a connection to DS is established
|
||||
// It means that, either from DNS lookup or ICE, we think we have a socket we can talk to DS on
|
||||
void completedSocketDiscovery();
|
||||
|
||||
void connectedToDomain(const QString& hostname);
|
||||
void disconnectedFromDomain();
|
||||
|
||||
void requestICEConnectionAttempt();
|
||||
|
||||
void settingsReceived(const QJsonObject& domainSettingsObject);
|
||||
|
@ -103,6 +115,7 @@ private:
|
|||
bool _isConnected;
|
||||
QJsonObject _settingsObject;
|
||||
int _failedSettingsRequests;
|
||||
QString _pendingPath;
|
||||
};
|
||||
|
||||
#endif // hifi_DomainHandler_h
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
HifiSockAddr(const sockaddr* sockaddr);
|
||||
|
||||
bool isNull() const { return _address.isNull() && _port == 0; }
|
||||
void clear() { _address = QHostAddress::Null; _port = 0;}
|
||||
|
||||
HifiSockAddr& operator=(const HifiSockAddr& rhsSockAddr);
|
||||
void swap(HifiSockAddr& otherSockAddr);
|
||||
|
|
|
@ -54,7 +54,12 @@ NodeList::NodeList(char newOwnerType, unsigned short socketListenPort, unsigned
|
|||
connect(addressManager.data(), &AddressManager::possibleDomainChangeRequiredViaICEForID,
|
||||
&_domainHandler, &DomainHandler::setIceServerHostnameAndID);
|
||||
|
||||
connect(addressManager.data(), &AddressManager::pathChangeRequired, this, &NodeList::sendDSPathQuery);
|
||||
// handle a request for a path change from the AddressManager
|
||||
connect(addressManager.data(), &AddressManager::pathChangeRequired, this, &NodeList::handleDSPathQuery);
|
||||
|
||||
// in case we don't know how to talk to DS when a path change is requested
|
||||
// fire off any pending DS path query when we get socket information
|
||||
connect(&_domainHandler, &DomainHandler::completedSocketDiscovery, this, &NodeList::sendPendingDSPathQuery);
|
||||
|
||||
// clear our NodeList when the domain changes
|
||||
connect(&_domainHandler, &DomainHandler::disconnectedFromDomain, this, &NodeList::reset);
|
||||
|
@ -401,9 +406,34 @@ void NodeList::sendDomainServerCheckIn() {
|
|||
}
|
||||
}
|
||||
|
||||
void NodeList::handleDSPathQuery(const QString& newPath) {
|
||||
if (_domainHandler.isSocketKnown()) {
|
||||
// if we have a DS socket we assume it will get this packet and send if off right away
|
||||
sendDSPathQuery(newPath);
|
||||
} else {
|
||||
// otherwise we make it pending so that it can be sent once a connection is established
|
||||
_domainHandler.setPendingPath(newPath);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeList::sendPendingDSPathQuery() {
|
||||
|
||||
QString pendingPath = _domainHandler.getPendingPath();
|
||||
|
||||
if (!pendingPath.isEmpty()) {
|
||||
qCDebug(networking) << "Attemping to send pending query to DS for path" << pendingPath;
|
||||
|
||||
// this is a slot triggered if we just established a network link with a DS and want to send a path query
|
||||
sendDSPathQuery(_domainHandler.getPendingPath());
|
||||
|
||||
// clear whatever the pending path was
|
||||
_domainHandler.clearPendingPath();
|
||||
}
|
||||
}
|
||||
|
||||
void NodeList::sendDSPathQuery(const QString& newPath) {
|
||||
// only send a path query if we know who our DS is or is going to be
|
||||
if (!_domainHandler.getSockAddr().isNull()) {
|
||||
if (_domainHandler.isSocketKnown()) {
|
||||
// construct the path query packet
|
||||
QByteArray pathQueryPacket = byteArrayWithPopulatedHeader(PacketTypeDomainServerPathQuery);
|
||||
|
||||
|
@ -420,12 +450,13 @@ void NodeList::sendDSPathQuery(const QString& newPath) {
|
|||
// append the path itself to the query packet
|
||||
pathQueryPacket.append(pathQueryUTF8);
|
||||
|
||||
qDebug() << "Sending a path query packet for path" << newPath << "to domain-server at" << _domainHandler.getSockAddr();
|
||||
qCDebug(networking) << "Sending a path query packet for path" << newPath << "to domain-server at"
|
||||
<< _domainHandler.getSockAddr();
|
||||
|
||||
// send off the path query
|
||||
writeUnverifiedDatagram(pathQueryPacket, _domainHandler.getSockAddr());
|
||||
} else {
|
||||
qDebug() << "Path" << newPath << "would make PacketTypeDomainServerPathQuery packet > MAX_PACKET_SIZE." <<
|
||||
qCDebug(networking) << "Path" << newPath << "would make PacketTypeDomainServerPathQuery packet > MAX_PACKET_SIZE." <<
|
||||
"Will not send query.";
|
||||
}
|
||||
}
|
||||
|
@ -462,9 +493,10 @@ void NodeList::handleDSPathQueryResponse(const QByteArray& packet) {
|
|||
|
||||
// Hand it off to the AddressManager so it can handle it as a relative viewpoint
|
||||
if (DependencyManager::get<AddressManager>()->goToViewpoint(viewpoint)) {
|
||||
qDebug() << "Going to viewpoint" << viewpoint << "which was the lookup result for path" << pathQuery;
|
||||
qCDebug(networking) << "Going to viewpoint" << viewpoint << "which was the lookup result for path" << pathQuery;
|
||||
} else {
|
||||
qDebug() << "Could not go to viewpoint" << viewpoint << "which was the lookup result for path" << pathQuery;
|
||||
qCDebug(networking) << "Could not go to viewpoint" << viewpoint
|
||||
<< "which was the lookup result for path" << pathQuery;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,9 +71,11 @@ public slots:
|
|||
void reset();
|
||||
void sendDomainServerCheckIn();
|
||||
void pingInactiveNodes();
|
||||
void sendDSPathQuery(const QString& newPath);
|
||||
void handleDSPathQuery(const QString& newPath);
|
||||
signals:
|
||||
void limitOfSilentDomainCheckInsReached();
|
||||
private slots:
|
||||
void sendPendingDSPathQuery();
|
||||
private:
|
||||
NodeList() : LimitedNodeList(0, 0) { assert(false); } // Not implemented, needed for DependencyManager templates compile
|
||||
NodeList(char ownerType, unsigned short socketListenPort = 0, unsigned short dtlsListenPort = 0);
|
||||
|
@ -92,6 +94,8 @@ private:
|
|||
|
||||
void handleDSPathQueryResponse(const QByteArray& packet);
|
||||
|
||||
void sendDSPathQuery(const QString& newPath);
|
||||
|
||||
NodeType_t _ownerType;
|
||||
NodeSet _nodeTypesOfInterest;
|
||||
DomainHandler _domainHandler;
|
||||
|
|
Loading…
Reference in a new issue