mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 01:17:14 +02:00
add both fulfilled and queued assignments to DS json
This commit is contained in:
parent
4cb657fa24
commit
1ed2b3d8fe
3 changed files with 43 additions and 4 deletions
|
@ -33,11 +33,11 @@ void DomainServer::setDomainServerInstance(DomainServer* domainServer) {
|
||||||
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);
|
||||||
|
|
||||||
const char TWO_HUNDRED_RESPONSE[] = "HTTP/1.0 200 OK\r\n\r\n";
|
const char RESPONSE_200[] = "HTTP/1.0 200 OK\r\n\r\n";
|
||||||
|
|
||||||
if (strcmp(ri->uri, "/assignment") == 0 && strcmp(ri->request_method, "POST") == 0) {
|
if (strcmp(ri->uri, "/assignment") == 0 && strcmp(ri->request_method, "POST") == 0) {
|
||||||
// return a 200
|
// return a 200
|
||||||
mg_printf(connection, "%s", TWO_HUNDRED_RESPONSE);
|
mg_printf(connection, "%s", RESPONSE_200);
|
||||||
// upload the file
|
// upload the file
|
||||||
mg_upload(connection, "/tmp");
|
mg_upload(connection, "/tmp");
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
||||||
// user is asking for json list of assignments
|
// user is asking for json list of assignments
|
||||||
|
|
||||||
// start with a 200 response
|
// start with a 200 response
|
||||||
mg_printf(connection, "%s", TWO_HUNDRED_RESPONSE);
|
mg_printf(connection, "%s", RESPONSE_200);
|
||||||
|
|
||||||
// setup the JSON
|
// setup the JSON
|
||||||
QJsonObject assignmentJSON;
|
QJsonObject assignmentJSON;
|
||||||
|
@ -85,8 +85,30 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assignmentJSON["fulfilled"] = assignedNodesJSON;
|
||||||
|
|
||||||
|
QJsonObject queuedAssignmentsJSON;
|
||||||
|
|
||||||
|
// add the queued but unfilled assignments to the json
|
||||||
|
std::deque<Assignment*>::iterator assignment = domainServerInstance->_assignmentQueue.begin();
|
||||||
|
|
||||||
|
while (assignment != domainServerInstance->_assignmentQueue.end()) {
|
||||||
|
QJsonObject queuedAssignmentJSON;
|
||||||
|
|
||||||
|
QString uuidString = uuidStringWithoutCurlyBraces((*assignment)->getUUID());
|
||||||
|
queuedAssignmentJSON[ASSIGNMENT_JSON_UUID_KEY] = uuidString;
|
||||||
|
|
||||||
|
// add this queued assignment to the JSON
|
||||||
|
queuedAssignmentsJSON[(*assignment)->getTypeName()] = queuedAssignmentJSON;
|
||||||
|
|
||||||
|
// push forward the iterator to check the next assignment
|
||||||
|
assignment++;
|
||||||
|
}
|
||||||
|
|
||||||
|
assignmentJSON["queued"] = queuedAssignmentsJSON;
|
||||||
|
|
||||||
// print out the created JSON
|
// print out the created JSON
|
||||||
QJsonDocument assignmentDocument(assignedNodesJSON);
|
QJsonDocument assignmentDocument(assignmentJSON);
|
||||||
mg_printf(connection, "%s", assignmentDocument.toJson().constData());
|
mg_printf(connection, "%s", assignmentDocument.toJson().constData());
|
||||||
|
|
||||||
// we've processed this request
|
// we've processed this request
|
||||||
|
|
|
@ -139,6 +139,21 @@ void Assignment::setPayload(const uchar* payload, int numBytes) {
|
||||||
memcpy(_payload, payload, _numPayloadBytes);
|
memcpy(_payload, payload, _numPayloadBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* Assignment::getTypeName() const {
|
||||||
|
switch (_type) {
|
||||||
|
case Assignment::AudioMixerType:
|
||||||
|
return "audio-mixer";
|
||||||
|
case Assignment::AvatarMixerType:
|
||||||
|
return "avatar-mixer";
|
||||||
|
case Assignment::AgentType:
|
||||||
|
return "agent";
|
||||||
|
case Assignment::VoxelServerType:
|
||||||
|
return "voxel-server";
|
||||||
|
default:
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int Assignment::packToBuffer(unsigned char* buffer) {
|
int Assignment::packToBuffer(unsigned char* buffer) {
|
||||||
int numPackedBytes = 0;
|
int numPackedBytes = 0;
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,8 @@ public:
|
||||||
int getNumberOfInstances() const { return _numberOfInstances; }
|
int getNumberOfInstances() const { return _numberOfInstances; }
|
||||||
void setNumberOfInstances(int numberOfInstances) { _numberOfInstances = numberOfInstances; }
|
void setNumberOfInstances(int numberOfInstances) { _numberOfInstances = numberOfInstances; }
|
||||||
void decrementNumberOfInstances() { --_numberOfInstances; }
|
void decrementNumberOfInstances() { --_numberOfInstances; }
|
||||||
|
|
||||||
|
const char* getTypeName() const;
|
||||||
|
|
||||||
/// Packs the assignment to the passed buffer
|
/// Packs the assignment to the passed buffer
|
||||||
/// \param buffer the buffer in which to pack the assignment
|
/// \param buffer the buffer in which to pack the assignment
|
||||||
|
|
Loading…
Reference in a new issue