mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-08 00:20:03 +02:00
working to integrate serverless domains into history, etc
This commit is contained in:
parent
b5fe5a0c23
commit
b2a4181bc0
7 changed files with 62 additions and 54 deletions
|
@ -2951,14 +2951,12 @@ void Application::setServersEnabled(bool serversEnabled) {
|
|||
qDebug() << "QQQQ serversEnabled =" << serversEnabled;
|
||||
if (_serversEnabled != serversEnabled) {
|
||||
_serversEnabled = serversEnabled;
|
||||
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
nodeList->getDomainHandler().setAPIRefreshTimerEnabled(serversEnabled);
|
||||
|
||||
if (!_serversEnabled) {
|
||||
nodeList->reset();
|
||||
clearDomainOctreeDetails();
|
||||
}
|
||||
// auto nodeList = DependencyManager::get<NodeList>();
|
||||
// nodeList->getDomainHandler().setAPIRefreshTimerEnabled(serversEnabled);
|
||||
// if (!_serversEnabled) {
|
||||
// nodeList->reset();
|
||||
// clearDomainOctreeDetails();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2969,8 +2967,8 @@ bool Application::visitServerlessDomain(const QString& urlString) {
|
|||
}
|
||||
|
||||
void Application::loadServerlessDomain(QUrl domainURL) {
|
||||
resettingDomain();
|
||||
domainChanged("");
|
||||
// resettingDomain();
|
||||
// domainChanged("");
|
||||
importJSONFromURL(domainURL.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ void WindowScriptingInterface::promptAsync(const QString& message, const QString
|
|||
}
|
||||
|
||||
void WindowScriptingInterface::disconnectedFromDomain() {
|
||||
emit domainChanged("");
|
||||
emit domainChanged("", QUrl());
|
||||
}
|
||||
|
||||
CustomPromptResult WindowScriptingInterface::customPrompt(const QVariant& config) {
|
||||
|
|
|
@ -547,7 +547,7 @@ signals:
|
|||
*
|
||||
* Window.domainChanged.connect(onDomainChanged);
|
||||
*/
|
||||
void domainChanged(const QString& domain);
|
||||
void domainChanged(const QString& domain, const QUrl& serverlessDomainURL);
|
||||
|
||||
/**jsdoc
|
||||
* Triggered when you try to navigate to a *.json, *.svo, or *.svo.json URL in a Web browser within Interface.
|
||||
|
|
|
@ -293,9 +293,9 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
|
|||
return true;
|
||||
|
||||
} else if (lookupUrl.scheme() == "http" || lookupUrl.scheme() == "https" || lookupUrl.scheme() == "file") {
|
||||
|
||||
qDebug() << "QQQQ do http before serverless domain" << lookupUrl.toString();
|
||||
qDebug() << "QQQQ file or http before serverless domain" << lookupUrl.toString();
|
||||
emit setServersEnabled(false);
|
||||
setDomainInfo(lookupUrl, QString(), 0, trigger);
|
||||
emit loadServerlessDomain(lookupUrl);
|
||||
emit lookupResultsFinished();
|
||||
return true;
|
||||
|
@ -387,6 +387,7 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
|
|||
QVariantMap domainObject = rootMap[LOCATION_API_DOMAIN_KEY].toMap();
|
||||
|
||||
if (!domainObject.isEmpty()) {
|
||||
// XXX serverless domain URL ?
|
||||
const QString DOMAIN_NETWORK_ADDRESS_KEY = "network_address";
|
||||
const QString DOMAIN_NETWORK_PORT_KEY = "network_port";
|
||||
const QString DOMAIN_ICE_SERVER_ADDRESS_KEY = "ice_server_address";
|
||||
|
@ -406,7 +407,7 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
|
|||
|
||||
qCDebug(networking) << "Possible domain change required to connect to" << domainHostname
|
||||
<< "on" << domainPort;
|
||||
emit possibleDomainChangeRequired(domainHostname, domainPort, domainID);
|
||||
emit possibleDomainChangeRequired(QUrl(), domainHostname, domainPort, domainID);
|
||||
} else {
|
||||
QString iceServerAddress = domainObject[DOMAIN_ICE_SERVER_ADDRESS_KEY].toString();
|
||||
|
||||
|
@ -578,7 +579,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString, LookupTri
|
|||
}
|
||||
|
||||
emit lookupResultsFinished();
|
||||
hostChanged = setDomainInfo(domainIPString, domainPort, trigger);
|
||||
hostChanged = setDomainInfo(QUrl(), domainIPString, domainPort, trigger);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -595,7 +596,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString, LookupTri
|
|||
}
|
||||
|
||||
emit lookupResultsFinished();
|
||||
hostChanged = setDomainInfo(domainHostname, domainPort, trigger);
|
||||
hostChanged = setDomainInfo(QUrl(), domainHostname, domainPort, trigger);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -739,7 +740,8 @@ bool AddressManager::setHost(const QString& host, LookupTrigger trigger, quint16
|
|||
return false;
|
||||
}
|
||||
|
||||
bool AddressManager::setDomainInfo(const QString& hostname, quint16 port, LookupTrigger trigger) {
|
||||
bool AddressManager::setDomainInfo(const QUrl& serverlessDomainURL,
|
||||
const QString& hostname, quint16 port, LookupTrigger trigger) {
|
||||
bool hostChanged = setHost(hostname, trigger, port);
|
||||
|
||||
// clear any current place information
|
||||
|
@ -750,7 +752,7 @@ bool AddressManager::setDomainInfo(const QString& hostname, quint16 port, Lookup
|
|||
|
||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::HandleAddress);
|
||||
|
||||
emit possibleDomainChangeRequired(hostname, port, QUuid());
|
||||
emit possibleDomainChangeRequired(serverlessDomainURL, hostname, port, QUuid());
|
||||
|
||||
return hostChanged;
|
||||
}
|
||||
|
|
|
@ -311,13 +311,15 @@ signals:
|
|||
/**jsdoc
|
||||
* Triggered when a request is made to go to an IP address.
|
||||
* @function location.possibleDomainChangeRequired
|
||||
* @param {string} serverlessDomainURL - URL for a file-based domain
|
||||
* @param {string} hostName - The name of the domain to go do.
|
||||
* @param {number} port - The integer number of the network port to connect to.
|
||||
* @param {Uuid} domainID - The UUID of the domain to go to.
|
||||
* @returns {Signal}
|
||||
*/
|
||||
// No example because this function isn't typically used in scripts.
|
||||
void possibleDomainChangeRequired(const QString& newHostname, quint16 newPort, const QUuid& domainID);
|
||||
void possibleDomainChangeRequired(const QUrl& serverlessDomainURL,
|
||||
const QString& newHostname, quint16 newPort, const QUuid& domainID);
|
||||
|
||||
/**jsdoc
|
||||
* Triggered when a request is made to go to a named domain or user.
|
||||
|
@ -432,7 +434,7 @@ private:
|
|||
|
||||
// Set host and port, and return `true` if it was changed.
|
||||
bool setHost(const QString& host, LookupTrigger trigger, quint16 port = 0);
|
||||
bool setDomainInfo(const QString& hostname, quint16 port, LookupTrigger trigger);
|
||||
bool setDomainInfo(const QUrl& serverlessDomainURL, const QString& hostname, quint16 port, LookupTrigger trigger);
|
||||
|
||||
const JSONCallbackParameters& apiCallbackParameters();
|
||||
|
||||
|
@ -453,6 +455,7 @@ private:
|
|||
QString _host;
|
||||
quint16 _port;
|
||||
QString _placeName;
|
||||
QUrl _filebasedDomainURL; // for serverless domains
|
||||
QUuid _rootPlaceID;
|
||||
PositionGetter _positionGetter;
|
||||
OrientationGetter _orientationGetter;
|
||||
|
@ -464,7 +467,7 @@ private:
|
|||
quint64 _lastBackPush = 0;
|
||||
|
||||
QString _newHostLookupPath;
|
||||
|
||||
|
||||
QUrl _previousLookup;
|
||||
};
|
||||
|
||||
|
|
|
@ -48,33 +48,23 @@ DomainHandler::DomainHandler(QObject* parent) :
|
|||
const int API_REFRESH_TIMEOUT_MSEC = 2500;
|
||||
_apiRefreshTimer.setInterval(API_REFRESH_TIMEOUT_MSEC); // 2.5s, Qt::CoarseTimer acceptable
|
||||
|
||||
connect(&_apiRefreshTimer, &QTimer::timeout, [this] {
|
||||
if (_apiRefreshTimerEnabled) {
|
||||
auto addressManager = DependencyManager::get<AddressManager>();
|
||||
if (addressManager) {
|
||||
addressManager->refreshPreviousLookup();
|
||||
}
|
||||
}
|
||||
});
|
||||
auto addressManager = DependencyManager::get<AddressManager>();
|
||||
connect(&_apiRefreshTimer, &QTimer::timeout, addressManager.data(), &AddressManager::refreshPreviousLookup);
|
||||
|
||||
// stop the refresh timer if we connect to a domain
|
||||
connect(this, &DomainHandler::connectedToDomain, &_apiRefreshTimer, &QTimer::stop);
|
||||
}
|
||||
|
||||
void DomainHandler::setAPIRefreshTimerEnabled(bool enabled) {
|
||||
_apiRefreshTimerEnabled = enabled;
|
||||
}
|
||||
|
||||
void DomainHandler::disconnect() {
|
||||
// if we're currently connected to a domain, send a disconnect packet on our way out
|
||||
if (_isConnected) {
|
||||
sendDisconnectPacket();
|
||||
}
|
||||
|
||||
|
||||
// clear member variables that hold the connection state to a domain
|
||||
_uuid = QUuid();
|
||||
_connectionToken = QUuid();
|
||||
|
||||
|
||||
_icePeer.reset();
|
||||
|
||||
if (requiresICE()) {
|
||||
|
@ -88,10 +78,10 @@ void DomainHandler::disconnect() {
|
|||
void DomainHandler::sendDisconnectPacket() {
|
||||
// The DomainDisconnect packet is not verified - we're relying on the eventual addition of DTLS to the
|
||||
// domain-server connection to stop greifing here
|
||||
|
||||
|
||||
// construct the disconnect packet once (an empty packet but sourced with our current session UUID)
|
||||
static auto disconnectPacket = NLPacket::create(PacketType::DomainDisconnectRequest, 0);
|
||||
|
||||
|
||||
// send the disconnect packet to the current domain server
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
nodeList->sendUnreliablePacket(*disconnectPacket, _sockAddr);
|
||||
|
@ -104,7 +94,7 @@ void DomainHandler::clearSettings() {
|
|||
void DomainHandler::softReset() {
|
||||
qCDebug(networking) << "Resetting current domain connection information.";
|
||||
disconnect();
|
||||
|
||||
|
||||
clearSettings();
|
||||
|
||||
_connectionDenialsSinceKeypairRegen = 0;
|
||||
|
@ -127,6 +117,7 @@ void DomainHandler::hardReset() {
|
|||
_iceServerSockAddr = HifiSockAddr();
|
||||
_hostname = QString();
|
||||
_sockAddr.clear();
|
||||
_serverlessDomainURL = QUrl();
|
||||
|
||||
_domainConnectionRefusals.clear();
|
||||
|
||||
|
@ -150,6 +141,7 @@ void DomainHandler::setSockAddr(const HifiSockAddr& sockAddr, const QString& hos
|
|||
|
||||
// some callers may pass a hostname, this is not to be used for lookup but for DTLS certificate verification
|
||||
_hostname = hostname;
|
||||
_serverlessDomainURL = QUrl();
|
||||
}
|
||||
|
||||
void DomainHandler::setUUID(const QUuid& uuid) {
|
||||
|
@ -159,27 +151,35 @@ void DomainHandler::setUUID(const QUuid& uuid) {
|
|||
}
|
||||
}
|
||||
|
||||
void DomainHandler::setSocketAndID(const QString& hostname, quint16 port, const QUuid& domainID) {
|
||||
void DomainHandler::setSocketAndID(const QUrl& serverlessDomainURL,
|
||||
const QString& hostname, quint16 port, const QUuid& domainID) {
|
||||
|
||||
_pendingDomainID = domainID;
|
||||
|
||||
if (hostname != _hostname || _sockAddr.getPort() != port) {
|
||||
if (serverlessDomainURL != _serverlessDomainURL || hostname != _hostname || _sockAddr.getPort() != port) {
|
||||
// re-set the domain info so that auth information is reloaded
|
||||
hardReset();
|
||||
|
||||
if (serverlessDomainURL != _serverlessDomainURL) {
|
||||
_serverlessDomainURL = serverlessDomainURL;
|
||||
}
|
||||
|
||||
if (hostname != _hostname) {
|
||||
// set the new hostname
|
||||
_hostname = hostname;
|
||||
|
||||
qCDebug(networking) << "Updated domain hostname to" << _hostname;
|
||||
|
||||
// re-set the sock addr to null and fire off a lookup of the IP address for this domain-server's hostname
|
||||
qCDebug(networking, "Looking up DS hostname %s.", _hostname.toLocal8Bit().constData());
|
||||
QHostInfo::lookupHost(_hostname, this, SLOT(completedHostnameLookup(const QHostInfo&)));
|
||||
if (!_hostname.isEmpty()) {
|
||||
// re-set the sock addr to null and fire off a lookup of the IP address for this domain-server's hostname
|
||||
qCDebug(networking, "Looking up DS hostname %s.", _hostname.toLocal8Bit().constData());
|
||||
QHostInfo::lookupHost(_hostname, this, SLOT(completedHostnameLookup(const QHostInfo&)));
|
||||
|
||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainHostname);
|
||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(
|
||||
LimitedNodeList::ConnectionStep::SetDomainHostname);
|
||||
|
||||
UserActivityLogger::getInstance().changedDomain(_hostname);
|
||||
UserActivityLogger::getInstance().changedDomain(_hostname);
|
||||
}
|
||||
emit hostnameChanged(_hostname);
|
||||
}
|
||||
|
||||
|
@ -197,10 +197,10 @@ void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname,
|
|||
if (_iceServerSockAddr.getAddress().toString() != iceServerHostname || id != _pendingDomainID) {
|
||||
// re-set the domain info to connect to new domain
|
||||
hardReset();
|
||||
|
||||
|
||||
// refresh our ICE client UUID to something new
|
||||
_iceClientID = QUuid::createUuid();
|
||||
|
||||
|
||||
_pendingDomainID = id;
|
||||
|
||||
HifiSockAddr* replaceableSockAddr = &_iceServerSockAddr;
|
||||
|
@ -227,6 +227,7 @@ void DomainHandler::activateICELocalSocket() {
|
|||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
|
||||
_sockAddr = _icePeer.getLocalSocket();
|
||||
_hostname = _sockAddr.getAddress().toString();
|
||||
_serverlessDomainURL = QUrl();
|
||||
emit completedSocketDiscovery();
|
||||
}
|
||||
|
||||
|
@ -234,6 +235,7 @@ void DomainHandler::activateICEPublicSocket() {
|
|||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
|
||||
_sockAddr = _icePeer.getPublicSocket();
|
||||
_hostname = _sockAddr.getAddress().toString();
|
||||
_serverlessDomainURL = QUrl();
|
||||
emit completedSocketDiscovery();
|
||||
}
|
||||
|
||||
|
@ -271,10 +273,12 @@ void DomainHandler::setIsConnected(bool isConnected) {
|
|||
_isConnected = isConnected;
|
||||
|
||||
if (_isConnected) {
|
||||
emit connectedToDomain(_hostname);
|
||||
emit connectedToDomain(_hostname, _serverlessDomainURL);
|
||||
|
||||
// we've connected to new domain - time to ask it for global settings
|
||||
requestDomainSettings();
|
||||
if (!_hostname.isEmpty()) {
|
||||
// we've connected to new domain - time to ask it for global settings
|
||||
requestDomainSettings();
|
||||
}
|
||||
|
||||
} else {
|
||||
emit disconnectedFromDomain();
|
||||
|
|
|
@ -141,7 +141,8 @@ public:
|
|||
void setAPIRefreshTimerEnabled(bool enabled);
|
||||
|
||||
public slots:
|
||||
void setSocketAndID(const QString& hostname, quint16 port = DEFAULT_DOMAIN_SERVER_PORT, const QUuid& id = QUuid());
|
||||
void setSocketAndID(const QUrl& serverlessDomainURL,
|
||||
const QString& hostname, quint16 port = DEFAULT_DOMAIN_SERVER_PORT, const QUuid& id = QUuid());
|
||||
void setIceServerHostnameAndID(const QString& iceServerHostname, const QUuid& id);
|
||||
|
||||
void processSettingsPacketList(QSharedPointer<ReceivedMessage> packetList);
|
||||
|
@ -162,7 +163,7 @@ signals:
|
|||
void completedSocketDiscovery();
|
||||
|
||||
void resetting();
|
||||
void connectedToDomain(const QString& hostname);
|
||||
void connectedToDomain(const QString& hostname, const QUrl& serverlessDomainURL);
|
||||
void disconnectedFromDomain();
|
||||
|
||||
void iceSocketAndIDReceived();
|
||||
|
@ -181,6 +182,7 @@ private:
|
|||
void hardReset();
|
||||
|
||||
QUuid _uuid;
|
||||
QUrl _serverlessDomainURL;
|
||||
QString _hostname;
|
||||
HifiSockAddr _sockAddr;
|
||||
QUuid _assignmentUUID;
|
||||
|
@ -200,7 +202,6 @@ private:
|
|||
int _checkInPacketsSinceLastReply { 0 };
|
||||
|
||||
QTimer _apiRefreshTimer;
|
||||
bool _apiRefreshTimerEnabled { true };
|
||||
};
|
||||
|
||||
#endif // hifi_DomainHandler_h
|
||||
|
|
Loading…
Reference in a new issue