mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
Merge pull request #5091 from birarda/master
store an in-memory history of the last addresses
This commit is contained in:
commit
73fce52407
3 changed files with 37 additions and 4 deletions
|
@ -14,10 +14,10 @@ var connectSound = SoundCache.getSound("file://" + Paths.resources + "sounds/sho
|
||||||
|
|
||||||
// setup the options needed for that sound
|
// setup the options needed for that sound
|
||||||
var connectSoundOptions = {
|
var connectSoundOptions = {
|
||||||
localOnly: true
|
localOnly: true
|
||||||
}
|
}
|
||||||
|
|
||||||
// play the sound locally once we get the first audio packet from a mixer
|
// play the sound locally once we get the first audio packet from a mixer
|
||||||
Audio.receivedFirstPacket.connect(function(){
|
Audio.receivedFirstPacket.connect(function(){
|
||||||
Audio.playSound(connectSound, connectSoundOptions);
|
Audio.playSound(connectSound, connectSoundOptions);
|
||||||
});
|
});
|
||||||
|
|
|
@ -35,6 +35,7 @@ AddressManager::AddressManager() :
|
||||||
_positionGetter(NULL),
|
_positionGetter(NULL),
|
||||||
_orientationGetter(NULL)
|
_orientationGetter(NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddressManager::isConnected() {
|
bool AddressManager::isConnected() {
|
||||||
|
@ -217,7 +218,7 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
|
||||||
const QString DOMAIN_NETWORK_PORT_KEY = "network_port";
|
const QString DOMAIN_NETWORK_PORT_KEY = "network_port";
|
||||||
const QString DOMAIN_ICE_SERVER_ADDRESS_KEY = "ice_server_address";
|
const QString DOMAIN_ICE_SERVER_ADDRESS_KEY = "ice_server_address";
|
||||||
|
|
||||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::HandleAddress);
|
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::HandleAddress);
|
||||||
|
|
||||||
const QString DOMAIN_ID_KEY = "id";
|
const QString DOMAIN_ID_KEY = "id";
|
||||||
QString domainIDString = domainObject[DOMAIN_ID_KEY].toString();
|
QString domainIDString = domainObject[DOMAIN_ID_KEY].toString();
|
||||||
|
@ -415,6 +416,9 @@ bool AddressManager::handleViewpoint(const QString& viewpointString, bool should
|
||||||
positionRegex.cap(2).toFloat(),
|
positionRegex.cap(2).toFloat(),
|
||||||
positionRegex.cap(3).toFloat());
|
positionRegex.cap(3).toFloat());
|
||||||
|
|
||||||
|
// we're about to jump positions - store the current address in our history
|
||||||
|
addCurrentAddressToHistory();
|
||||||
|
|
||||||
if (!isNaN(newPosition.x) && !isNaN(newPosition.y) && !isNaN(newPosition.z)) {
|
if (!isNaN(newPosition.x) && !isNaN(newPosition.y) && !isNaN(newPosition.z)) {
|
||||||
glm::quat newOrientation;
|
glm::quat newOrientation;
|
||||||
|
|
||||||
|
@ -467,6 +471,10 @@ bool AddressManager::handleUsername(const QString& lookupString) {
|
||||||
|
|
||||||
void AddressManager::setHost(const QString& host) {
|
void AddressManager::setHost(const QString& host) {
|
||||||
if (host != _host) {
|
if (host != _host) {
|
||||||
|
|
||||||
|
// if the host is being changed we should store current address in the history
|
||||||
|
addCurrentAddressToHistory();
|
||||||
|
|
||||||
_host = host;
|
_host = host;
|
||||||
emit hostChanged(_host);
|
emit hostChanged(_host);
|
||||||
}
|
}
|
||||||
|
@ -474,7 +482,8 @@ void AddressManager::setHost(const QString& host) {
|
||||||
|
|
||||||
|
|
||||||
void AddressManager::setDomainInfo(const QString& hostname, quint16 port) {
|
void AddressManager::setDomainInfo(const QString& hostname, quint16 port) {
|
||||||
_host = hostname;
|
setHost(hostname);
|
||||||
|
|
||||||
_rootPlaceID = QUuid();
|
_rootPlaceID = QUuid();
|
||||||
|
|
||||||
qCDebug(networking) << "Possible domain change required to connect to domain at" << hostname << "on" << port;
|
qCDebug(networking) << "Possible domain change required to connect to domain at" << hostname << "on" << port;
|
||||||
|
@ -500,3 +509,22 @@ void AddressManager::copyAddress() {
|
||||||
void AddressManager::copyPath() {
|
void AddressManager::copyPath() {
|
||||||
QApplication::clipboard()->setText(currentPath());
|
QApplication::clipboard()->setText(currentPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddressManager::addCurrentAddressToHistory() {
|
||||||
|
if (_lastHistoryAppend == 0) {
|
||||||
|
// we don't store the first address on application load
|
||||||
|
// just update the last append time so the next is stored
|
||||||
|
_lastHistoryAppend = usecTimestampNow();
|
||||||
|
} else {
|
||||||
|
const quint64 DOUBLE_STORE_THRESHOLD_USECS = 500000;
|
||||||
|
|
||||||
|
// avoid double storing when the host changes and the viewpoint changes immediately after
|
||||||
|
if (usecTimestampNow() - _lastHistoryAppend > DOUBLE_STORE_THRESHOLD_USECS) {
|
||||||
|
// add the current address to the history
|
||||||
|
_history.append(currentAddress());
|
||||||
|
|
||||||
|
// change our last history append to now
|
||||||
|
_lastHistoryAppend = usecTimestampNow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -98,10 +98,15 @@ private:
|
||||||
bool handleUsername(const QString& lookupString);
|
bool handleUsername(const QString& lookupString);
|
||||||
bool handleDomainID(const QString& host);
|
bool handleDomainID(const QString& host);
|
||||||
|
|
||||||
|
void addCurrentAddressToHistory();
|
||||||
|
|
||||||
QString _host;
|
QString _host;
|
||||||
QUuid _rootPlaceID;
|
QUuid _rootPlaceID;
|
||||||
PositionGetter _positionGetter;
|
PositionGetter _positionGetter;
|
||||||
OrientationGetter _orientationGetter;
|
OrientationGetter _orientationGetter;
|
||||||
|
|
||||||
|
QList<QUrl> _history;
|
||||||
|
quint64 _lastHistoryAppend = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AddressManager_h
|
#endif // hifi_AddressManager_h
|
||||||
|
|
Loading…
Reference in a new issue