|
@@ -156,7 +156,7 @@ void MachineIoManager::run() {
|
|
|
break;
|
|
|
}
|
|
|
case CMD_GET: {
|
|
|
- int chunks;
|
|
|
+ int chunks, rec = 0;
|
|
|
std::vector<char> wtmp;
|
|
|
char wbuf[BLOCKSIZE];
|
|
|
if(tokens.size() < 2) {
|
|
@@ -182,7 +182,6 @@ void MachineIoManager::run() {
|
|
|
if(recv["accept"].asBool()) {
|
|
|
// for ACK
|
|
|
root["command"] = "get";
|
|
|
- root["remaining"] = 0;
|
|
|
root["cancel"] = false;
|
|
|
// request ok, start receiving
|
|
|
chunks = std::numeric_limits<int>::max();
|
|
@@ -195,10 +194,12 @@ void MachineIoManager::run() {
|
|
|
wtmp = base64::decodeVector(recv["data"].asString());
|
|
|
fs.write(wtmp.data(), wtmp.size());
|
|
|
chunks = recv["remaining"].asInt();
|
|
|
+ root["received"] = rec;
|
|
|
if(!sendJson(root)) {
|
|
|
// couldnt ACK
|
|
|
break;
|
|
|
}
|
|
|
+ rec++;
|
|
|
}
|
|
|
}
|
|
|
if(recv["cancel"].asBool()) std::cerr << "transfer was cancelled" << std::endl;
|