|
@@ -205,6 +205,41 @@ void MachineIoManager::run() {
|
|
|
if(recv["remaining"].asInt()) std::cerr << "not all data received, remain chunks " << recv["remaining"].asInt();
|
|
|
break;
|
|
|
}
|
|
|
+ case CMD_LIST: {
|
|
|
+ int chunks, rec = 0;
|
|
|
+ root["command"] = "list";
|
|
|
+ if(!sendJson(root) | !receiveJson(recvbuf) | !parseJson(&recv, recvbuf)) {
|
|
|
+ // error occured, stop working
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ // dump received data for GUI
|
|
|
+ std::cout << recv << std::endl;
|
|
|
+
|
|
|
+ if(recv["accept"].asBool()) {
|
|
|
+ // ACK?
|
|
|
+ root["command"] = "list";
|
|
|
+ root["cancel"] = false;
|
|
|
+ chunks = std::numeric_limits<int>::max();
|
|
|
+ while(chunks) {
|
|
|
+ if(!receiveJson(recvbuf) | !parseJson(&recv, recvbuf)) break;
|
|
|
+ // dump received data for GUI
|
|
|
+ std::cout << recv << std::endl;
|
|
|
+ /*
|
|
|
+ Json::Value arraything = recv["names"];
|
|
|
+ if(arraything.isArray())
|
|
|
+ for(Json::Value d : recv["names"])
|
|
|
+ */
|
|
|
+ chunks = recv["remaining"].asInt();
|
|
|
+ root["received"] = rec;
|
|
|
+ if(!sendJson(root)) {
|
|
|
+ // couldnt ACK
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ rec++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
default: {
|
|
|
std::cerr << "unknown command " << line << "\n";
|
|
|
break;
|