Browse Source

Fix get command so it acts according to protocol

The get command did not send a confirmation before sending the file.
anon 5 years ago
parent
commit
94dba6170f
1 changed files with 14 additions and 0 deletions
  1. 14 0
      daemon/src/Server.cpp

+ 14 - 0
daemon/src/Server.cpp

@@ -349,6 +349,20 @@ void con_handler::handle_read_command(const boost::system::error_code &err,
                                               placeholders::error,
                                               placeholders::bytes_transferred));
           } else {
+            answer["accept"] = true;
+
+            const std::string answerString =
+                Json::writeString(stringBuilder, answer);
+
+            sock.async_write_some(buffer(answerString, max_length),
+                                  boost::bind(&con_handler::handle_write,
+                                              shared_from_this(),
+                                              placeholders::error,
+                                              placeholders::bytes_transferred));
+
+            answer = Json::Value();
+            answer["command"] = "get";
+
             // get size of file
             size_t size = this->getFile.tellg();
             this->getFile.seekg(std::ios::beg);