From 407bf8847c2ed391833909233c95faf66cda195b Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期五, 12 六月 2020 10:01:26 +0800 Subject: [PATCH] add factory --- service/netdisk_service.c | 22 ++++++---------------- 1 files changed, 6 insertions(+), 16 deletions(-) diff --git a/service/netdisk_service.c b/service/netdisk_service.c index c71a014..bed648c 100644 --- a/service/netdisk_service.c +++ b/service/netdisk_service.c @@ -4,14 +4,13 @@ #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); @@ -23,7 +22,7 @@ PropertiesConfig config("../data/config.txt"); -SafeQueue<Netdisk_DownloadRequest> task_queue(10); +SafeQueue<Netdisk_DownloadRequest> task_queue(100); std::map<std::string, Netdisk *> userDeviceMap; @@ -78,14 +77,12 @@ 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()); - } } @@ -162,14 +159,7 @@ } 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); } } -- Gitblit v1.8.0