mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-06 07:12:37 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi
This commit is contained in:
commit
1167ecdf77
3 changed files with 29 additions and 42 deletions
|
@ -490,25 +490,29 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QString&
|
||||||
// this is a script upload - ask the HTTPConnection to parse the form data
|
// this is a script upload - ask the HTTPConnection to parse the form data
|
||||||
QList<FormData> formData = connection->parseFormData();
|
QList<FormData> formData = connection->parseFormData();
|
||||||
|
|
||||||
// create an assignment for this saved script
|
|
||||||
Assignment* scriptAssignment = new Assignment(Assignment::CreateCommand, Assignment::AgentType);
|
|
||||||
|
|
||||||
// check how many instances of this assignment the user wants by checking the ASSIGNMENT-INSTANCES header
|
// check how many instances of this assignment the user wants by checking the ASSIGNMENT-INSTANCES header
|
||||||
const QString ASSIGNMENT_INSTANCES_HEADER = "ASSIGNMENT-INSTANCES";
|
const QString ASSIGNMENT_INSTANCES_HEADER = "ASSIGNMENT-INSTANCES";
|
||||||
|
|
||||||
QByteArray assignmentInstancesValue = connection->requestHeaders().value(ASSIGNMENT_INSTANCES_HEADER.toLocal8Bit());
|
QByteArray assignmentInstancesValue = connection->requestHeaders().value(ASSIGNMENT_INSTANCES_HEADER.toLocal8Bit());
|
||||||
|
|
||||||
|
int numInstances = 1;
|
||||||
|
|
||||||
if (!assignmentInstancesValue.isEmpty()) {
|
if (!assignmentInstancesValue.isEmpty()) {
|
||||||
// the user has requested a specific number of instances
|
// the user has requested a specific number of instances
|
||||||
// so set that on the created assignment
|
// so set that on the created assignment
|
||||||
int numInstances = assignmentInstancesValue.toInt();
|
|
||||||
if (numInstances > 0) {
|
numInstances = assignmentInstancesValue.toInt();
|
||||||
qDebug() << numInstances;
|
|
||||||
scriptAssignment->setNumberOfInstances(numInstances);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char ASSIGNMENT_SCRIPT_HOST_LOCATION[] = "resources/web/assignment";
|
const char ASSIGNMENT_SCRIPT_HOST_LOCATION[] = "resources/web/assignment";
|
||||||
|
|
||||||
|
for (int i = 0; i < numInstances; i++) {
|
||||||
|
|
||||||
|
// create an assignment for this saved script
|
||||||
|
Assignment* scriptAssignment = new Assignment(Assignment::CreateCommand, Assignment::AgentType);
|
||||||
|
|
||||||
QString newPath(ASSIGNMENT_SCRIPT_HOST_LOCATION);
|
QString newPath(ASSIGNMENT_SCRIPT_HOST_LOCATION);
|
||||||
newPath += "/";
|
newPath += "/";
|
||||||
// append the UUID for this script as the new filename, remove the curly braces
|
// append the UUID for this script as the new filename, remove the curly braces
|
||||||
|
@ -521,12 +525,13 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QString&
|
||||||
|
|
||||||
qDebug("Saved a script for assignment at %s", qPrintable(newPath));
|
qDebug("Saved a script for assignment at %s", qPrintable(newPath));
|
||||||
|
|
||||||
// respond with a 200 code for successful upload
|
|
||||||
connection->respond(HTTPConnection::StatusCode200);
|
|
||||||
|
|
||||||
// add the script assigment to the assignment queue
|
// add the script assigment to the assignment queue
|
||||||
_assignmentQueue.enqueue(SharedAssignmentPointer(scriptAssignment));
|
_assignmentQueue.enqueue(SharedAssignmentPointer(scriptAssignment));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// respond with a 200 code for successful upload
|
||||||
|
connection->respond(HTTPConnection::StatusCode200);
|
||||||
|
}
|
||||||
} else if (connection->requestOperation() == QNetworkAccessManager::DeleteOperation) {
|
} else if (connection->requestOperation() == QNetworkAccessManager::DeleteOperation) {
|
||||||
if (path.startsWith(URI_NODE)) {
|
if (path.startsWith(URI_NODE)) {
|
||||||
// this is a request to DELETE a node by UUID
|
// this is a request to DELETE a node by UUID
|
||||||
|
@ -639,14 +644,7 @@ SharedAssignmentPointer DomainServer::deployableAssignmentForRequest(const Assig
|
||||||
|
|
||||||
if (assignment->getType() == Assignment::AgentType) {
|
if (assignment->getType() == Assignment::AgentType) {
|
||||||
// if there is more than one instance to send out, simply decrease the number of instances
|
// if there is more than one instance to send out, simply decrease the number of instances
|
||||||
|
|
||||||
if (assignment->getNumberOfInstances() == 1) {
|
|
||||||
return _assignmentQueue.takeAt(sharedAssignment - _assignmentQueue.begin());
|
return _assignmentQueue.takeAt(sharedAssignment - _assignmentQueue.begin());
|
||||||
} else {
|
|
||||||
assignment->decrementNumberOfInstances();
|
|
||||||
return *sharedAssignment;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// remove the assignment from the queue
|
// remove the assignment from the queue
|
||||||
SharedAssignmentPointer deployableAssignment = _assignmentQueue.takeAt(sharedAssignment
|
SharedAssignmentPointer deployableAssignment = _assignmentQueue.takeAt(sharedAssignment
|
||||||
|
|
|
@ -45,7 +45,6 @@ Assignment::Assignment() :
|
||||||
_type(Assignment::AllTypes),
|
_type(Assignment::AllTypes),
|
||||||
_pool(),
|
_pool(),
|
||||||
_location(Assignment::LocalLocation),
|
_location(Assignment::LocalLocation),
|
||||||
_numberOfInstances(1),
|
|
||||||
_payload()
|
_payload()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -57,7 +56,6 @@ Assignment::Assignment(Assignment::Command command, Assignment::Type type, const
|
||||||
_type(type),
|
_type(type),
|
||||||
_pool(pool),
|
_pool(pool),
|
||||||
_location(location),
|
_location(location),
|
||||||
_numberOfInstances(1),
|
|
||||||
_payload()
|
_payload()
|
||||||
{
|
{
|
||||||
if (_command == Assignment::CreateCommand) {
|
if (_command == Assignment::CreateCommand) {
|
||||||
|
@ -69,7 +67,6 @@ Assignment::Assignment(Assignment::Command command, Assignment::Type type, const
|
||||||
Assignment::Assignment(const QByteArray& packet) :
|
Assignment::Assignment(const QByteArray& packet) :
|
||||||
_pool(),
|
_pool(),
|
||||||
_location(GlobalLocation),
|
_location(GlobalLocation),
|
||||||
_numberOfInstances(1),
|
|
||||||
_payload()
|
_payload()
|
||||||
{
|
{
|
||||||
PacketType packetType = packetTypeForPacket(packet);
|
PacketType packetType = packetTypeForPacket(packet);
|
||||||
|
@ -99,7 +96,6 @@ Assignment::Assignment(const Assignment& otherAssignment) {
|
||||||
_type = otherAssignment._type;
|
_type = otherAssignment._type;
|
||||||
_location = otherAssignment._location;
|
_location = otherAssignment._location;
|
||||||
_pool = otherAssignment._pool;
|
_pool = otherAssignment._pool;
|
||||||
_numberOfInstances = otherAssignment._numberOfInstances;
|
|
||||||
_payload = otherAssignment._payload;
|
_payload = otherAssignment._payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,8 +113,6 @@ void Assignment::swap(Assignment& otherAssignment) {
|
||||||
swap(_type, otherAssignment._type);
|
swap(_type, otherAssignment._type);
|
||||||
swap(_location, otherAssignment._location);
|
swap(_location, otherAssignment._location);
|
||||||
swap(_pool, otherAssignment._pool);
|
swap(_pool, otherAssignment._pool);
|
||||||
|
|
||||||
swap(_numberOfInstances, otherAssignment._numberOfInstances);
|
|
||||||
swap(_payload, otherAssignment._payload);
|
swap(_payload, otherAssignment._payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,10 +80,6 @@ public:
|
||||||
void setPool(const QString& pool) { _pool = pool; };
|
void setPool(const QString& pool) { _pool = pool; };
|
||||||
const QString& getPool() const { return _pool; }
|
const QString& getPool() const { return _pool; }
|
||||||
|
|
||||||
int getNumberOfInstances() const { return _numberOfInstances; }
|
|
||||||
void setNumberOfInstances(int numberOfInstances) { _numberOfInstances = numberOfInstances; }
|
|
||||||
void decrementNumberOfInstances() { --_numberOfInstances; }
|
|
||||||
|
|
||||||
const char* getTypeName() const;
|
const char* getTypeName() const;
|
||||||
|
|
||||||
// implement parseData to return 0 so we can be a subclass of NodeData
|
// implement parseData to return 0 so we can be a subclass of NodeData
|
||||||
|
@ -99,7 +95,6 @@ protected:
|
||||||
Assignment::Type _type; /// the type of the assignment, defines what the assignee will do
|
Assignment::Type _type; /// the type of the assignment, defines what the assignee will do
|
||||||
QString _pool; /// the destination pool for this assignment
|
QString _pool; /// the destination pool for this assignment
|
||||||
Assignment::Location _location; /// the location of the assignment, allows a domain to preferentially use local ACs
|
Assignment::Location _location; /// the location of the assignment, allows a domain to preferentially use local ACs
|
||||||
int _numberOfInstances; /// the number of instances of this assignment
|
|
||||||
QByteArray _payload; /// an optional payload attached to this assignment, a maximum for 1024 bytes will be packed
|
QByteArray _payload; /// an optional payload attached to this assignment, a maximum for 1024 bytes will be packed
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue