void CopySenderServer::PhysicalServerDoneNotify(int BuildID){ QString jsonMessage = startJSONMessage(); appendJSONValue(jsonMessage, "handler","PhysicalServerDone", true); appendJSONValue(jsonMessage, "BuildID", QString::number(BuildID),false); endJSONMessage(jsonMessage); sendJSONMessage(socket, jsonMessage); }
void CopySenderServer::SendDifferences(){ //loop through all the directories in order to state which is different //on the client for(int i = 0; i < differentBuildIDs->size(); i++){ //if it is the first time it is connected write to the client which builds //should generate the MD5classes for QString jsonMessage = startJSONMessage(); appendJSONValue(jsonMessage, "handler", "BuildDifferent", true); appendJSONValue(jsonMessage, "differentBuildID", differentBuildIDs->at(i),false); endJSONMessage(jsonMessage); sendJSONMessage(socket, jsonMessage); } QString jsonMessage = startJSONMessage(); appendJSONValue(jsonMessage, "handler", "EndAllDifferences", false); endJSONMessage(jsonMessage); sendJSONMessage(socket, jsonMessage); }
void ProtoSizeCheckBuilds::invokeSizeCheckAll(QTcpSocket *slaveSocket){ /*The following is to create a loop to continually update the build until the build is fully synched */ QString jsonMessage = startJSONMessage(); appendJSONValue(jsonMessage, "handler", "ProtoSizeCheckBuilds", true); appendJSONValue(jsonMessage, "subHandler", "SizeCheckAllBuilds", false); endJSONMessage(jsonMessage); sendJSONMessage(slaveSocket, jsonMessage); }
void CopySenderServer::requestHandler(QString data){ JSON *instance = &JSON::instance(); //go and parse the json to an object concurrently... QFuture <QVariantMap>future = QtConcurrent::run(instance, &JSON::parse, data); const QVariantMap jsonObject = future.result();//finally retrieve the jsonObject after it has been parsed QVariant handler = jsonObject.value("handler"); if(!handler.toString().compare("QVariant(, )")){ qDebug()<< "invalid JSON String::"<<data; } if(firstTalk){ if(!handler.toString().compare("HelloCopySender")){ //check whether the machine is the right machine that should connect to it... if(jsonObject.value("machineID").toString().compare(QString::number(machineId))){ socket->disconnectFromHost(); return; }else{ //if it is the right machine continue firstTalk = false; //stop the server since you don't want to allow any other connections stopServer(); } }else{ socket->disconnectFromHost(); return; } QString jsonMessage = startJSONMessage(); appendJSONValue(jsonMessage, "handler", "HelloCopyReceiver", false); endJSONMessage(jsonMessage); sendJSONMessage(socket, jsonMessage); return; } if(!handler.toString().compare("SendDifferences")) SendDifferences(); else if(!handler.toString().compare("BuildFileSumMD5")) BuildFileSumMD5(jsonObject); else if(!handler.toString().compare("NotifyCopySuccess")) NotifyCopySuccess(jsonObject); }
void ProtoSlaveCurrentBuilds::SizeCheckAllBuilds(QTcpSocket *slaveSocket){ /*The following is to create a loop to continually update the build until the information is updated **Same is done in the bottom of protosizecheckallbuilds */ QString jsonMessage = startJSONMessage(); appendJSONValue(jsonMessage, "handler", "ProtoSizeCheckBuilds", true); appendJSONValue(jsonMessage, "subHandler", "SizeCheckAllBuilds", false); endJSONMessage(jsonMessage); sendJSONMessage(slaveSocket, jsonMessage); }
void ProtoSendStructure::BuildStructureRequest(QVariantMap jsonObject, Management *management, QTcpSocket *slaveSocket){ //get the structure for the build and send it across the network QString StringBuildID = jsonObject.value("buildID").toString(); bool ok = false; int buildID = StringBuildID.toInt(&ok); if(!ok) return; QString buildDIR = management->getBuildByID(buildID)->getBuildDirectory(); //go and get the structure QStringList structure = DirectoryHandler::getDirectoryStructure(buildDIR); //place the structure of directories inside a json format QString jsonMessage = startJSONMessage(); appendJSONValue(jsonMessage, "handler", "ProtoSendStructure", true); appendJSONValue(jsonMessage, "subHandler","DuplicateStructure", true); appendJSONValue(jsonMessage, "buildID", StringBuildID, true); //start a new json value and append the list to it QString jsonStructureValue = "\"structure\" : {"; for(int i = 0; i < structure.size(); i++){ //append all the values as json QString directoryNumber = QString::number(i); QString aPath; //there is no comma at end of json values if(i == structure.size()-1) aPath = "\"" + directoryNumber + "\" : \"" + structure.at(i) + "\""; else aPath = "\"" + directoryNumber + "\" : \"" + structure.at(i) + "\","; jsonStructureValue.append(aPath); } //end the list of structures(directory paths) jsonStructureValue.append("}"); //append the list of all the structures jsonMessage.append(jsonStructureValue); endJSONMessage(jsonMessage); sendJSONMessage(slaveSocket, jsonMessage); }
void sendNumericalMessage(const char* name, float value, Listener* listener) { sendJSONMessage(name, cJSON_CreateNumber(value), NULL, listener); }
void sendEventedStringMessage(const char* name, const char* value, const char* event, Listener* listener) { sendJSONMessage(name, cJSON_CreateString(value), cJSON_CreateString(event), listener); }
void sendEventedFloatMessage(const char* name, const char* value, float event, Listener* listener) { sendJSONMessage(name, cJSON_CreateString(value), cJSON_CreateNumber(event), listener); }
void sendStringMessage(const char* name, const char* value, Listener* listener) { sendJSONMessage(name, cJSON_CreateString(value), NULL, listener); }
void sendBooleanMessage(const char* name, bool value, Listener* listener) { sendJSONMessage(name, cJSON_CreateBool(value), NULL, listener); }