mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 18:10:37 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi
This commit is contained in:
commit
d16242f980
4 changed files with 44 additions and 42 deletions
|
@ -23,8 +23,8 @@ $(document).ready(function(){
|
||||||
|
|
||||||
$.each(json.queued, function (uuid, data) {
|
$.each(json.queued, function (uuid, data) {
|
||||||
queuedTableBody += "<tr>";
|
queuedTableBody += "<tr>";
|
||||||
queuedTableBody += "<td>" + uuid + "</td>";
|
|
||||||
queuedTableBody += "<td>" + data.type + "</td>";
|
queuedTableBody += "<td>" + data.type + "</td>";
|
||||||
|
queuedTableBody += "<td>" + uuid + "</td>";
|
||||||
queuedTableBody += "<td>" + (data.pool ? data.pool : "") + "</td>";
|
queuedTableBody += "<td>" + (data.pool ? data.pool : "") + "</td>";
|
||||||
queuedTableBody += "</tr>";
|
queuedTableBody += "</tr>";
|
||||||
});
|
});
|
||||||
|
|
|
@ -374,7 +374,7 @@ void DomainServer::readAvailableDatagrams() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject jsonForSocket(const HifiSockAddr& socket) {
|
QJsonObject DomainServer::jsonForSocket(const HifiSockAddr& socket) {
|
||||||
QJsonObject socketJSON;
|
QJsonObject socketJSON;
|
||||||
|
|
||||||
socketJSON["ip"] = socket.getAddress().toString();
|
socketJSON["ip"] = socket.getAddress().toString();
|
||||||
|
@ -388,7 +388,7 @@ const char JSON_KEY_PUBLIC_SOCKET[] = "public";
|
||||||
const char JSON_KEY_LOCAL_SOCKET[] = "local";
|
const char JSON_KEY_LOCAL_SOCKET[] = "local";
|
||||||
const char JSON_KEY_POOL[] = "pool";
|
const char JSON_KEY_POOL[] = "pool";
|
||||||
|
|
||||||
QJsonObject jsonObjectForNode(Node* node) {
|
QJsonObject DomainServer::jsonObjectForNode(const SharedNodePointer& node) {
|
||||||
QJsonObject nodeJson;
|
QJsonObject nodeJson;
|
||||||
|
|
||||||
// re-format the type name so it matches the target name
|
// re-format the type name so it matches the target name
|
||||||
|
@ -402,12 +402,13 @@ QJsonObject jsonObjectForNode(Node* node) {
|
||||||
// add the node socket information
|
// add the node socket information
|
||||||
nodeJson[JSON_KEY_PUBLIC_SOCKET] = jsonForSocket(node->getPublicSocket());
|
nodeJson[JSON_KEY_PUBLIC_SOCKET] = jsonForSocket(node->getPublicSocket());
|
||||||
nodeJson[JSON_KEY_LOCAL_SOCKET] = jsonForSocket(node->getLocalSocket());
|
nodeJson[JSON_KEY_LOCAL_SOCKET] = jsonForSocket(node->getLocalSocket());
|
||||||
|
|
||||||
// if the node has pool information, add it
|
// if the node has pool information, add it
|
||||||
if (node->getLinkedData() && !((Assignment*) node->getLinkedData())->getPool().isEmpty()) {
|
SharedAssignmentPointer matchingAssignment = _staticAssignmentHash.value(node->getUUID());
|
||||||
nodeJson[JSON_KEY_POOL] = ((Assignment*) node->getLinkedData())->getPool();
|
if (matchingAssignment) {
|
||||||
|
nodeJson[JSON_KEY_POOL] = matchingAssignment->getPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
return nodeJson;
|
return nodeJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,10 +428,10 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QString&
|
||||||
|
|
||||||
// enumerate the NodeList to find the assigned nodes
|
// enumerate the NodeList to find the assigned nodes
|
||||||
foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
|
foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
|
||||||
if (node->getLinkedData()) {
|
if (_staticAssignmentHash.value(node->getUUID())) {
|
||||||
// add the node using the UUID as the key
|
// add the node using the UUID as the key
|
||||||
QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID());
|
QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID());
|
||||||
assignedNodesJSON[uuidString] = jsonObjectForNode(node.data());
|
assignedNodesJSON[uuidString] = jsonObjectForNode(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,7 +474,7 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QString&
|
||||||
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
|
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
|
||||||
// add the node using the UUID as the key
|
// add the node using the UUID as the key
|
||||||
QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID());
|
QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID());
|
||||||
nodesJSON[uuidString] = jsonObjectForNode(node.data());
|
nodesJSON[uuidString] = jsonObjectForNode(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
rootJSON["nodes"] = nodesJSON;
|
rootJSON["nodes"] = nodesJSON;
|
||||||
|
|
|
@ -48,6 +48,9 @@ private:
|
||||||
void removeMatchingAssignmentFromQueue(const SharedAssignmentPointer& removableAssignment);
|
void removeMatchingAssignmentFromQueue(const SharedAssignmentPointer& removableAssignment);
|
||||||
void refreshStaticAssignmentAndAddToQueue(SharedAssignmentPointer& assignment);
|
void refreshStaticAssignmentAndAddToQueue(SharedAssignmentPointer& assignment);
|
||||||
|
|
||||||
|
QJsonObject jsonForSocket(const HifiSockAddr& socket);
|
||||||
|
QJsonObject jsonObjectForNode(const SharedNodePointer& node);
|
||||||
|
|
||||||
HTTPManager _HTTPManager;
|
HTTPManager _HTTPManager;
|
||||||
|
|
||||||
QHash<QUuid, SharedAssignmentPointer> _staticAssignmentHash;
|
QHash<QUuid, SharedAssignmentPointer> _staticAssignmentHash;
|
||||||
|
|
|
@ -184,39 +184,37 @@ void NodeList::setDomainHostname(const QString& domainHostname) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::timePingReply(const QByteArray& packet, const SharedNodePointer& sendingNode) {
|
void NodeList::timePingReply(const QByteArray& packet, const SharedNodePointer& sendingNode) {
|
||||||
|
QDataStream packetStream(packet);
|
||||||
|
packetStream.skipRawData(numBytesForPacketHeader(packet));
|
||||||
|
|
||||||
if (sendingNode) {
|
quint8 pingType;
|
||||||
QDataStream packetStream(packet);
|
quint64 ourOriginalTime, othersReplyTime;
|
||||||
packetStream.skipRawData(numBytesForPacketHeader(packet));
|
|
||||||
|
packetStream >> pingType >> ourOriginalTime >> othersReplyTime;
|
||||||
quint64 ourOriginalTime, othersReplyTime;
|
|
||||||
|
quint64 now = usecTimestampNow();
|
||||||
packetStream >> ourOriginalTime >> othersReplyTime;
|
int pingTime = now - ourOriginalTime;
|
||||||
|
int oneWayFlightTime = pingTime / 2; // half of the ping is our one way flight
|
||||||
quint64 now = usecTimestampNow();
|
|
||||||
int pingTime = now - ourOriginalTime;
|
// The other node's expected time should be our original time plus the one way flight time
|
||||||
int oneWayFlightTime = pingTime / 2; // half of the ping is our one way flight
|
// anything other than that is clock skew
|
||||||
|
quint64 othersExprectedReply = ourOriginalTime + oneWayFlightTime;
|
||||||
// The other node's expected time should be our original time plus the one way flight time
|
int clockSkew = othersReplyTime - othersExprectedReply;
|
||||||
// anything other than that is clock skew
|
|
||||||
quint64 othersExprectedReply = ourOriginalTime + oneWayFlightTime;
|
sendingNode->setPingMs(pingTime / 1000);
|
||||||
int clockSkew = othersReplyTime - othersExprectedReply;
|
sendingNode->setClockSkewUsec(clockSkew);
|
||||||
|
|
||||||
sendingNode->setPingMs(pingTime / 1000);
|
const bool wantDebug = false;
|
||||||
sendingNode->setClockSkewUsec(clockSkew);
|
|
||||||
|
if (wantDebug) {
|
||||||
const bool wantDebug = false;
|
qDebug() << "PING_REPLY from node " << *sendingNode << "\n" <<
|
||||||
|
" now: " << now << "\n" <<
|
||||||
if (wantDebug) {
|
" ourTime: " << ourOriginalTime << "\n" <<
|
||||||
qDebug() << "PING_REPLY from node " << *sendingNode << "\n" <<
|
" pingTime: " << pingTime << "\n" <<
|
||||||
" now: " << now << "\n" <<
|
" oneWayFlightTime: " << oneWayFlightTime << "\n" <<
|
||||||
" ourTime: " << ourOriginalTime << "\n" <<
|
" othersReplyTime: " << othersReplyTime << "\n" <<
|
||||||
" pingTime: " << pingTime << "\n" <<
|
" othersExprectedReply: " << othersExprectedReply << "\n" <<
|
||||||
" oneWayFlightTime: " << oneWayFlightTime << "\n" <<
|
" clockSkew: " << clockSkew;
|
||||||
" othersReplyTime: " << othersReplyTime << "\n" <<
|
|
||||||
" othersExprectedReply: " << othersExprectedReply << "\n" <<
|
|
||||||
" clockSkew: " << clockSkew;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue