mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 18:16:45 +02:00
Merge branch 'master' of https://github.com/worklist/hifi
This commit is contained in:
commit
3ba7f6ca36
4 changed files with 46 additions and 32 deletions
|
@ -87,6 +87,9 @@ void Agent::run() {
|
||||||
// send a user agent since some servers will require it
|
// send a user agent since some servers will require it
|
||||||
curl_easy_setopt(curlHandle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
|
curl_easy_setopt(curlHandle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
|
||||||
|
|
||||||
|
// make sure CURL fails on a 400 code
|
||||||
|
curl_easy_setopt(curlHandle, CURLOPT_FAILONERROR, true);
|
||||||
|
|
||||||
qDebug() << "Downloading script at" << scriptURLString << "\n";
|
qDebug() << "Downloading script at" << scriptURLString << "\n";
|
||||||
|
|
||||||
// blocking get for JS file
|
// blocking get for JS file
|
||||||
|
|
|
@ -4,14 +4,14 @@ $(document).ready(function(){
|
||||||
$.getJSON("nodes.json", function(json){
|
$.getJSON("nodes.json", function(json){
|
||||||
nodesTableBody = "";
|
nodesTableBody = "";
|
||||||
|
|
||||||
$.each(json.nodes, function (type, data) {
|
$.each(json.nodes, function (uuid, data) {
|
||||||
nodesTableBody += "<tr>";
|
nodesTableBody += "<tr>";
|
||||||
nodesTableBody += "<td>" + type + "</td>";
|
nodesTableBody += "<td>" + data.type + "</td>";
|
||||||
nodesTableBody += "<td>" + data.UUID + "</td>";
|
nodesTableBody += "<td>" + uuid + "</td>";
|
||||||
nodesTableBody += "<td>" + (data.pool ? data.pool : "") + "</td>";
|
nodesTableBody += "<td>" + (data.pool ? data.pool : "") + "</td>";
|
||||||
nodesTableBody += "<td>" + data.public.ip + "<span class='port'>:" + data.public.port + "</span></td>";
|
nodesTableBody += "<td>" + data.public.ip + "<span class='port'>:" + data.public.port + "</span></td>";
|
||||||
nodesTableBody += "<td>" + data.local.ip + "<span class='port'>:" + data.local.port + "</span></td>";
|
nodesTableBody += "<td>" + data.local.ip + "<span class='port'>:" + data.local.port + "</span></td>";
|
||||||
nodesTableBody += "<td><span class='glyphicon glyphicon-remove' data-uuid=" + data.UUID + "></span></td>";
|
nodesTableBody += "<td><span class='glyphicon glyphicon-remove' data-uuid=" + uuid + "></span></td>";
|
||||||
nodesTableBody += "</tr>";
|
nodesTableBody += "</tr>";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -21,10 +21,10 @@ $(document).ready(function(){
|
||||||
$.getJSON("assignments.json", function(json){
|
$.getJSON("assignments.json", function(json){
|
||||||
queuedTableBody = "";
|
queuedTableBody = "";
|
||||||
|
|
||||||
$.each(json.queued, function (type, data) {
|
$.each(json.queued, function (uuid, data) {
|
||||||
queuedTableBody += "<tr>";
|
queuedTableBody += "<tr>";
|
||||||
queuedTableBody += "<td>" + type + "</td>";
|
queuedTableBody += "<td>" + uuid + "</td>";
|
||||||
queuedTableBody += "<td>" + data.UUID + "</td>";
|
queuedTableBody += "<td>" + data.type + "</td>";
|
||||||
queuedTableBody += "<td>" + (data.pool ? data.pool : "") + "</td>";
|
queuedTableBody += "<td>" + (data.pool ? data.pool : "") + "</td>";
|
||||||
queuedTableBody += "</tr>";
|
queuedTableBody += "</tr>";
|
||||||
});
|
});
|
||||||
|
|
|
@ -42,28 +42,32 @@ QJsonObject jsonForSocket(sockaddr* socket) {
|
||||||
return socketJSON;
|
return socketJSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char JSON_KEY_UUID[] = "UUID";
|
const char JSON_KEY_TYPE[] = "type";
|
||||||
const char JSON_KEY_PUBLIC_SOCKET[] = "public";
|
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";
|
||||||
|
|
||||||
void addNodeToJsonObject(Node* node, QJsonObject& jsonObject) {
|
QJsonObject jsonObjectForNode(Node* node) {
|
||||||
QJsonObject nodeJson;
|
QJsonObject nodeJson;
|
||||||
|
|
||||||
// add the UUID
|
|
||||||
QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID());
|
|
||||||
nodeJson[JSON_KEY_UUID] = uuidString;
|
|
||||||
|
|
||||||
// add the node socket information
|
|
||||||
nodeJson[JSON_KEY_PUBLIC_SOCKET] = jsonForSocket(node->getPublicSocket());
|
|
||||||
nodeJson[JSON_KEY_LOCAL_SOCKET] = jsonForSocket(node->getLocalSocket());
|
|
||||||
|
|
||||||
// re-format the type name so it matches the target name
|
// re-format the type name so it matches the target name
|
||||||
QString nodeTypeName(node->getTypeName());
|
QString nodeTypeName(node->getTypeName());
|
||||||
nodeTypeName = nodeTypeName.toLower();
|
nodeTypeName = nodeTypeName.toLower();
|
||||||
nodeTypeName.replace(' ', '-');
|
nodeTypeName.replace(' ', '-');
|
||||||
|
|
||||||
jsonObject[nodeTypeName] = nodeJson;
|
// add the node type
|
||||||
|
nodeJson[JSON_KEY_TYPE] = nodeTypeName;
|
||||||
|
|
||||||
|
// add the node socket information
|
||||||
|
nodeJson[JSON_KEY_PUBLIC_SOCKET] = jsonForSocket(node->getPublicSocket());
|
||||||
|
nodeJson[JSON_KEY_LOCAL_SOCKET] = jsonForSocket(node->getLocalSocket());
|
||||||
|
|
||||||
|
// if the node has pool information, add it
|
||||||
|
if (node->getLinkedData() && ((Assignment*) node->getLinkedData())->hasPool()) {
|
||||||
|
nodeJson[JSON_KEY_POOL] = QString(((Assignment*) node->getLinkedData())->getPool());
|
||||||
|
}
|
||||||
|
|
||||||
|
return nodeJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
||||||
|
@ -91,7 +95,9 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
||||||
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
||||||
if (node->getLinkedData()) {
|
if (node->getLinkedData()) {
|
||||||
addNodeToJsonObject(&(*node), assignedNodesJSON);
|
// add the node using the UUID as the key
|
||||||
|
QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID());
|
||||||
|
assignedNodesJSON[uuidString] = jsonObjectForNode(&(*node));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,10 +112,15 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
||||||
QJsonObject queuedAssignmentJSON;
|
QJsonObject queuedAssignmentJSON;
|
||||||
|
|
||||||
QString uuidString = uuidStringWithoutCurlyBraces((*assignment)->getUUID());
|
QString uuidString = uuidStringWithoutCurlyBraces((*assignment)->getUUID());
|
||||||
queuedAssignmentJSON[JSON_KEY_UUID] = uuidString;
|
queuedAssignmentJSON[JSON_KEY_TYPE] = QString((*assignment)->getTypeName());
|
||||||
|
|
||||||
|
// if the assignment has a pool, add it
|
||||||
|
if ((*assignment)->hasPool()) {
|
||||||
|
queuedAssignmentJSON[JSON_KEY_POOL] = QString((*assignment)->getPool());
|
||||||
|
}
|
||||||
|
|
||||||
// add this queued assignment to the JSON
|
// add this queued assignment to the JSON
|
||||||
queuedAssignmentsJSON[(*assignment)->getTypeName()] = queuedAssignmentJSON;
|
queuedAssignmentsJSON[uuidString] = queuedAssignmentJSON;
|
||||||
|
|
||||||
// push forward the iterator to check the next assignment
|
// push forward the iterator to check the next assignment
|
||||||
assignment++;
|
assignment++;
|
||||||
|
@ -135,7 +146,9 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
||||||
addNodeToJsonObject(&(*node), nodesJSON);
|
// add the node using the UUID as the key
|
||||||
|
QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID());
|
||||||
|
nodesJSON[uuidString] = jsonObjectForNode(&(*node));
|
||||||
}
|
}
|
||||||
|
|
||||||
rootJSON["nodes"] = nodesJSON;
|
rootJSON["nodes"] = nodesJSON;
|
||||||
|
|
|
@ -435,21 +435,19 @@ void VoxelServer::run() {
|
||||||
nodeData->initializeVoxelSendThread(this);
|
nodeData->initializeVoxelSendThread(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (packetData[0] == PACKET_TYPE_PING
|
|
||||||
|| packetData[0] == PACKET_TYPE_DOMAIN
|
|
||||||
|| packetData[0] == PACKET_TYPE_STUN_RESPONSE) {
|
|
||||||
// let processNodeData handle it.
|
|
||||||
NodeList::getInstance()->processNodeData(&senderAddress, packetData, packetLength);
|
|
||||||
} else if (packetData[0] == PACKET_TYPE_DOMAIN) {
|
|
||||||
NodeList::getInstance()->processNodeData(&senderAddress, packetData, packetLength);
|
|
||||||
} else if (packetData[0] == PACKET_TYPE_VOXEL_JURISDICTION_REQUEST) {
|
} else if (packetData[0] == PACKET_TYPE_VOXEL_JURISDICTION_REQUEST) {
|
||||||
if (_jurisdictionSender) {
|
if (_jurisdictionSender) {
|
||||||
_jurisdictionSender->queueReceivedPacket(senderAddress, packetData, packetLength);
|
_jurisdictionSender->queueReceivedPacket(senderAddress, packetData, packetLength);
|
||||||
}
|
}
|
||||||
} else if (_voxelServerPacketProcessor) {
|
} else if (_voxelServerPacketProcessor &&
|
||||||
|
(packetData[0] == PACKET_TYPE_SET_VOXEL
|
||||||
|
|| packetData[0] == PACKET_TYPE_SET_VOXEL_DESTRUCTIVE
|
||||||
|
|| packetData[0] == PACKET_TYPE_ERASE_VOXEL
|
||||||
|
|| packetData[0] == PACKET_TYPE_Z_COMMAND)) {
|
||||||
_voxelServerPacketProcessor->queueReceivedPacket(senderAddress, packetData, packetLength);
|
_voxelServerPacketProcessor->queueReceivedPacket(senderAddress, packetData, packetLength);
|
||||||
} else {
|
} else {
|
||||||
qDebug("unknown packet ignored... packetData[0]=%c\n", packetData[0]);
|
// let processNodeData handle it.
|
||||||
|
NodeList::getInstance()->processNodeData(&senderAddress, packetData, packetLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue