This commit is contained in:
Andrzej Kapolka 2014-11-04 15:10:19 -08:00
commit 576ac23e71
5 changed files with 40 additions and 15 deletions

View file

@ -1148,7 +1148,7 @@ void DomainServer::performICEUpdates() {
}
void DomainServer::sendHeartbeatToIceServer() {
const HifiSockAddr ICE_SERVER_SOCK_ADDR = HifiSockAddr("ice.highfidelity.io", ICE_SERVER_DEFAULT_PORT);
static HifiSockAddr ICE_SERVER_SOCK_ADDR = HifiSockAddr("ice.highfidelity.io", ICE_SERVER_DEFAULT_PORT);
LimitedNodeList::getInstance()->sendHeartbeatToIceServer(ICE_SERVER_SOCK_ADDR);
}

View file

@ -56,7 +56,6 @@ public:
void setEyeOffsetOrientation(const glm::quat& o) { _eyeOffsetOrientation = o; }
void setScale(const float s) { _scale = s; }
glm::vec3 getPosition() const { return _position + _hmdPosition; }
glm::quat getRotation() const { return _rotation * _hmdRotation; }
const glm::vec3& getHmdPosition() const { return _hmdPosition; }
const glm::quat& getHmdRotation() const { return _hmdRotation; }
@ -73,6 +72,7 @@ public slots:
QString getModeString() const;
void setModeString(const QString& mode);
glm::vec3 getPosition() const { return _position + _hmdPosition; }
void setPosition(const glm::vec3& position) { _position = position; }
void setOrientation(const glm::quat& orientation) { setRotation(orientation); }

View file

@ -14,6 +14,7 @@
#include <QtCore/QJsonDocument>
#include "Assignment.h"
#include "HifiSockAddr.h"
#include "NodeList.h"
#include "PacketHeaders.h"
#include "UserActivityLogger.h"
@ -144,7 +145,10 @@ void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname,
hardReset();
_iceDomainID = id;
_iceServerSockAddr = HifiSockAddr(iceServerHostname, ICE_SERVER_DEFAULT_PORT);
HifiSockAddr* replaceableSockAddr = &_iceServerSockAddr;
replaceableSockAddr->~HifiSockAddr();
replaceableSockAddr = new (replaceableSockAddr) HifiSockAddr(iceServerHostname, ICE_SERVER_DEFAULT_PORT);
// refresh our ICE client UUID to something new
_iceClientID = QUuid::createUuid();

View file

@ -31,9 +31,17 @@ HifiSockAddr::HifiSockAddr(const QHostAddress& address, quint16 port) :
}
HifiSockAddr::HifiSockAddr(const HifiSockAddr& otherSockAddr) {
_address = otherSockAddr._address;
_port = otherSockAddr._port;
HifiSockAddr::HifiSockAddr(const HifiSockAddr& otherSockAddr) :
_address(otherSockAddr._address),
_port(otherSockAddr._port)
{
}
HifiSockAddr& HifiSockAddr::operator=(const HifiSockAddr& rhsSockAddr) {
HifiSockAddr temp(rhsSockAddr);
swap(temp);
return *this;
}
HifiSockAddr::HifiSockAddr(const QString& hostname, quint16 hostOrderPort, bool shouldBlockForLookup) :
@ -44,12 +52,12 @@ HifiSockAddr::HifiSockAddr(const QString& hostname, quint16 hostOrderPort, bool
if (_address.protocol() != QAbstractSocket::IPv4Protocol) {
// lookup the IP by the hostname
if (shouldBlockForLookup) {
qDebug() << "Asynchronously looking up IP address for hostname" << hostname;
qDebug() << "Synchronously looking up IP address for hostname" << hostname;
QHostInfo result = QHostInfo::fromName(hostname);
handleLookupResult(result);
} else {
int lookupID = QHostInfo::lookupHost(hostname, this, SLOT(handleLookupResult(QHostInfo)));
qDebug() << "Synchronously looking up IP address for hostname" << hostname << "- lookup ID is" << lookupID;
qDebug() << "Asynchronously looking up IP address for hostname" << hostname << "- lookup ID is" << lookupID;
}
}
}
@ -64,13 +72,6 @@ HifiSockAddr::HifiSockAddr(const sockaddr* sockaddr) {
}
}
HifiSockAddr& HifiSockAddr::operator=(const HifiSockAddr& rhsSockAddr) {
_address = rhsSockAddr._address;
_port = rhsSockAddr._port;
return *this;
}
void HifiSockAddr::swap(HifiSockAddr& otherSockAddr) {
using std::swap;

View file

@ -46,6 +46,26 @@ quint64 usecTimestampNow() {
TIME_REFERENCE = QDateTime::currentMSecsSinceEpoch() * 1000; // ms to usec
timestampTimer.start();
usecTimestampNowIsInitialized = true;
} else {
// We've seen the QElapsedTimer begin to introduce dramatic errors if it's been
// continuously running for a long time. So we will periodically reset it.
const quint64 SECS_TO_NSECS = 1000000000;
const quint64 RESET_AFTER_ELAPSED_SECS = 60 * 60; // 1 hour: 60 minutes * 60 seconds
const quint64 RESET_AFTER_ELAPSED_NSECS = RESET_AFTER_ELAPSED_SECS * SECS_TO_NSECS;
const quint64 nsecsElapsed = timestampTimer.nsecsElapsed();
if (nsecsElapsed > RESET_AFTER_ELAPSED_NSECS) {
quint64 msecsElapsed = timestampTimer.restart();
quint64 usecsElapsed = nsecsElapsed / 1000; // nsec to usec
TIME_REFERENCE += usecsElapsed;
const bool wantDebug = false;
if (wantDebug) {
qDebug() << "usecTimestampNow() - resetting QElapsedTimer. ";
qDebug() << " RESET_AFTER_ELAPSED_NSECS:" << RESET_AFTER_ELAPSED_NSECS;
qDebug() << " nsecsElapsed:" << nsecsElapsed;
qDebug() << " msecsElapsed:" << msecsElapsed;
qDebug() << " usecsElapsed:" << usecsElapsed;
}
}
}
// usec nsec to usec usec