|
@@ -180,6 +180,65 @@ void con_handler::handle_read_command(const boost::system::error_code &err,
|
|
|
answer["response"] = "This is a status message :)";
|
|
|
const std::string answerString = Json::writeString(stringBuilder, answer);
|
|
|
|
|
|
+ // send answer
|
|
|
+ sock.async_write_some(buffer(answerString, max_length),
|
|
|
+ boost::bind(&con_handler::handle_write,
|
|
|
+ shared_from_this(), placeholders::error,
|
|
|
+ placeholders::bytes_transferred));
|
|
|
+
|
|
|
+ // read next data
|
|
|
+ sock.async_read_some(buffer(data, max_length),
|
|
|
+ boost::bind(&con_handler::handle_read_command,
|
|
|
+ shared_from_this(), placeholders::error,
|
|
|
+ placeholders::bytes_transferred));
|
|
|
+ } else if (root["command"].compare("list") == 0) {
|
|
|
+ answer["command"] = "list";
|
|
|
+
|
|
|
+ // TODO look for real data
|
|
|
+ Json::Value array;
|
|
|
+ array.append("some");
|
|
|
+ array.append("important");
|
|
|
+ array.append("data");
|
|
|
+ answer["names"] = array;
|
|
|
+ answer["remaining"] = 0;
|
|
|
+
|
|
|
+ const std::string answerString = Json::writeString(stringBuilder, answer);
|
|
|
+ // send answer
|
|
|
+ sock.async_write_some(buffer(answerString, max_length),
|
|
|
+ boost::bind(&con_handler::handle_write,
|
|
|
+ shared_from_this(), placeholders::error,
|
|
|
+ placeholders::bytes_transferred));
|
|
|
+
|
|
|
+ // read next data
|
|
|
+ sock.async_read_some(buffer(data, max_length),
|
|
|
+ boost::bind(&con_handler::handle_read_command,
|
|
|
+ shared_from_this(), placeholders::error,
|
|
|
+ placeholders::bytes_transferred));
|
|
|
+ } else if (root["command"].compare("put") == 0) {
|
|
|
+ answer["command"] = "put";
|
|
|
+
|
|
|
+ // TODO establish real connection and receive file
|
|
|
+ answer["accept"] = false;
|
|
|
+
|
|
|
+ const std::string answerString = Json::writeString(stringBuilder, answer);
|
|
|
+ // send answer
|
|
|
+ sock.async_write_some(buffer(answerString, max_length),
|
|
|
+ boost::bind(&con_handler::handle_write,
|
|
|
+ shared_from_this(), placeholders::error,
|
|
|
+ placeholders::bytes_transferred));
|
|
|
+
|
|
|
+ // read next data
|
|
|
+ sock.async_read_some(buffer(data, max_length),
|
|
|
+ boost::bind(&con_handler::handle_read_command,
|
|
|
+ shared_from_this(), placeholders::error,
|
|
|
+ placeholders::bytes_transferred));
|
|
|
+ } else if (root["command"].compare("get") == 0) {
|
|
|
+ answer["command"] = "get";
|
|
|
+
|
|
|
+ // TODO establish real connection and send file
|
|
|
+ answer["accept"] = false;
|
|
|
+
|
|
|
+ const std::string answerString = Json::writeString(stringBuilder, answer);
|
|
|
// send answer
|
|
|
sock.async_write_some(buffer(answerString, max_length),
|
|
|
boost::bind(&con_handler::handle_write,
|