| | |
| | | #include "login_store.h" |
| | | #include "request_handler.h" |
| | | #include "properties_config.h" |
| | | #include "netdisk_factory.h" |
| | | #include <jsoncpp/json/json.h> |
| | | #include <nng/nng.h> |
| | | #include <nng/protocol/reqrep0/rep.h> |
| | | #include <nng/protocol/reqrep0/req.h> |
| | | |
| | | using namespace std; |
| | | |
| | | |
| | | |
| | | static int work(Netdisk_DownloadRequest drequest); |
| | | static int connectAndSend(const char *url, char * str); |
| | |
| | | |
| | | PropertiesConfig config("../data/config.txt"); |
| | | |
| | | SafeQueue<Netdisk_DownloadRequest> task_queue(10); |
| | | SafeQueue<Netdisk_DownloadRequest> task_queue(100); |
| | | |
| | | std::map<std::string, Netdisk *> userDeviceMap; |
| | | |
| | |
| | | |
| | | Netdisk_LoginInfo loginInfo = loginStore.getLoginInfo(drequest.loginUUID); |
| | | if (netdisk == NULL) { |
| | | |
| | | if(loginInfo.deviceType == "HC") { |
| | | // std::cout << "new HCNetdisk" << std::endl; |
| | | netdisk = new HCNetdisk(); |
| | | |
| | | netdisk = NetdiskFacotory::create(loginInfo.deviceType); |
| | | if(netdisk != NULL) { |
| | | userDeviceMap.insert({loginInfo.loginUUID, netdisk}); |
| | | } else { |
| | | err_msg(0, "无法识别的设备类型: %s", loginInfo.deviceType.c_str()); |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | } else { |
| | | std::cerr << "Don't support " << method << std::endl; |
| | | } |
| | | // if (method == "login") { |
| | | // handleLogin(sock, request); |
| | | // } else if (method == "downloadByTime") { |
| | | // handleDownloadByTimeAsync(sock, request); |
| | | // } else { |
| | | // std::cerr << "Don't support " << method << std::endl; |
| | | // } |
| | | // Unrecognized command, so toss the buffer. |
| | | |
| | | nng_free(buf, sz); |
| | | } |
| | | } |