mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 20:16:16 +02:00
Merge pull request #1079 from birarda/assignment
add local node information to assignments JSON
This commit is contained in:
commit
43d13406ae
1 changed files with 15 additions and 8 deletions
|
@ -30,6 +30,18 @@ void DomainServer::setDomainServerInstance(DomainServer* domainServer) {
|
||||||
domainServerInstance = domainServer;
|
domainServerInstance = domainServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonObject jsonForSocket(sockaddr* socket) {
|
||||||
|
QJsonObject socketJSON;
|
||||||
|
|
||||||
|
if (socket->sa_family == AF_INET) {
|
||||||
|
sockaddr_in* socketIPv4 = (sockaddr_in*) socket;
|
||||||
|
socketJSON["ip"] = QString(inet_ntoa(socketIPv4->sin_addr));
|
||||||
|
socketJSON["port"] = (int) ntohs(socketIPv4->sin_port);
|
||||||
|
}
|
||||||
|
|
||||||
|
return socketJSON;
|
||||||
|
}
|
||||||
|
|
||||||
int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
||||||
const struct mg_request_info* ri = mg_get_request_info(connection);
|
const struct mg_request_info* ri = mg_get_request_info(connection);
|
||||||
|
|
||||||
|
@ -67,14 +79,9 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
||||||
QString assignmentUUID = uuidStringWithoutCurlyBraces(((Assignment*) node->getLinkedData())->getUUID());
|
QString assignmentUUID = uuidStringWithoutCurlyBraces(((Assignment*) node->getLinkedData())->getUUID());
|
||||||
assignedNodeJSON[ASSIGNMENT_JSON_UUID_KEY] = assignmentUUID;
|
assignedNodeJSON[ASSIGNMENT_JSON_UUID_KEY] = assignmentUUID;
|
||||||
|
|
||||||
QJsonObject nodePublicSocketJSON;
|
// add the node socket information
|
||||||
|
assignedNodeJSON["public"] = jsonForSocket(node->getPublicSocket());
|
||||||
// add the public socket information
|
assignedNodeJSON["local"] = jsonForSocket(node->getLocalSocket());
|
||||||
sockaddr_in* nodePublicSocket = (sockaddr_in*) node->getPublicSocket();
|
|
||||||
nodePublicSocketJSON["ip"] = QString(inet_ntoa(nodePublicSocket->sin_addr));
|
|
||||||
nodePublicSocketJSON["port"] = (int) ntohs(nodePublicSocket->sin_port);
|
|
||||||
|
|
||||||
assignedNodeJSON["public"] = nodePublicSocketJSON;
|
|
||||||
|
|
||||||
// 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());
|
||||||
|
|
Loading…
Reference in a new issue