rename:更改打印名称,避免冲突。
This commit is contained in:
		
							parent
							
								
									3356ceee67
								
							
						
					
					
						commit
						eabbc5dbec
					
				@ -52,7 +52,7 @@ void CClient::run(const std::string& ip, const std::string& port)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    th_run_ = true;
 | 
					    th_run_ = true;
 | 
				
			||||||
    if (!client_->connect(ip, port)) {
 | 
					    if (!client_->connect(ip, port)) {
 | 
				
			||||||
        pinfo("{} connect err.", __FUNCTION__);
 | 
					        mpinfo("{} connect err.", __FUNCTION__);
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    client_->register_func([&](CFrameBuffer* buf) { handle_frame(buf); });
 | 
					    client_->register_func([&](CFrameBuffer* buf) { handle_frame(buf); });
 | 
				
			||||||
@ -65,7 +65,7 @@ void CClient::run(const std::string& ip, const std::string& port)
 | 
				
			|||||||
    send_frame(bf);
 | 
					    send_frame(bf);
 | 
				
			||||||
    delete bf;
 | 
					    delete bf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pwarn("SupportCmd:Get|Up|Down|Cancel|Update");
 | 
					    mpwarn("SupportCmd:Get|Up|Down|Cancel|Update");
 | 
				
			||||||
    fc_append('|');
 | 
					    fc_append('|');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while (1) {
 | 
					    while (1) {
 | 
				
			||||||
@ -74,7 +74,7 @@ void CClient::run(const std::string& ip, const std::string& port)
 | 
				
			|||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (!th_run_ || !client_->is_normal()) {
 | 
					        if (!th_run_ || !client_->is_normal()) {
 | 
				
			||||||
            pwarn("The link has been closed and cannot be continued. It will automatically exit.");
 | 
					            mpwarn("The link has been closed and cannot be continued. It will automatically exit.");
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        std::string cmd_input(readline);
 | 
					        std::string cmd_input(readline);
 | 
				
			||||||
@ -96,7 +96,7 @@ void CClient::run(const std::string& ip, const std::string& port)
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        auto vec = COfStr::split(cmd_input, " ");
 | 
					        auto vec = COfStr::split(cmd_input, " ");
 | 
				
			||||||
        if (vec.size() < 2) {
 | 
					        if (vec.size() < 2) {
 | 
				
			||||||
            perror("No matched cmd, May be param size incorrect.");
 | 
					            mperror("No matched cmd, May be param size incorrect.");
 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        std::string param(cmd_input);
 | 
					        std::string param(cmd_input);
 | 
				
			||||||
@ -115,11 +115,11 @@ void CClient::run(const std::string& ip, const std::string& port)
 | 
				
			|||||||
            up_task(param);
 | 
					            up_task(param);
 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        perror("No matched cmd, May be param size incorrect.");
 | 
					        mperror("No matched cmd, May be param size incorrect.");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    client_->disconnect();
 | 
					    client_->disconnect();
 | 
				
			||||||
    thread.join();
 | 
					    thread.join();
 | 
				
			||||||
    pinfo("{} exit.", __FUNCTION__);
 | 
					    mpinfo("{} exit.", __FUNCTION__);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool CClient::get_task_list()
 | 
					bool CClient::get_task_list()
 | 
				
			||||||
@ -132,17 +132,17 @@ bool CClient::get_task_list()
 | 
				
			|||||||
bool CClient::down_task(const std::string& param)
 | 
					bool CClient::down_task(const std::string& param)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (downloading_) {
 | 
					    if (downloading_) {
 | 
				
			||||||
        pwarn("Have Task Downloading, Please wait.....");
 | 
					        mpwarn("Have Task Downloading, Please wait.....");
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    int id = std::stoi(param);
 | 
					    int id = std::stoi(param);
 | 
				
			||||||
    if (!task_list_.count(id)) {
 | 
					    if (!task_list_.count(id)) {
 | 
				
			||||||
        perror("No matched id[{}] in task list.", id);
 | 
					        mperror("No matched id[{}] in task list.", id);
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (task_list_[id]->id == own_id_) {
 | 
					    if (task_list_[id]->id == own_id_) {
 | 
				
			||||||
        pwarn("You can't down your own file!!!");
 | 
					        mpwarn("You can't down your own file!!!");
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -150,7 +150,7 @@ bool CClient::down_task(const std::string& param)
 | 
				
			|||||||
    down_ = std::make_shared<TransInfomation>();
 | 
					    down_ = std::make_shared<TransInfomation>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (vec.empty()) {
 | 
					    if (vec.empty()) {
 | 
				
			||||||
        pwarn("No files List, Please Check!");
 | 
					        mpwarn("No files List, Please Check!");
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -171,7 +171,7 @@ bool CClient::up_task(const std::string& param)
 | 
				
			|||||||
        std::lock_guard<std::mutex> lock(mutex_);
 | 
					        std::lock_guard<std::mutex> lock(mutex_);
 | 
				
			||||||
        for (const auto& item : up_) {
 | 
					        for (const auto& item : up_) {
 | 
				
			||||||
            if (item.second->trans_state_ == TRANS_REDAY || item.second->trans_state_ == TRANS_ING) {
 | 
					            if (item.second->trans_state_ == TRANS_REDAY || item.second->trans_state_ == TRANS_ING) {
 | 
				
			||||||
                pwarn("Have Task Upping, Please wait!");
 | 
					                mpwarn("Have Task Upping, Please wait!");
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -182,12 +182,12 @@ bool CClient::up_task(const std::string& param)
 | 
				
			|||||||
    for (const auto& item : list) {
 | 
					    for (const auto& item : list) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!fs::exists(item)) {
 | 
					        if (!fs::exists(item)) {
 | 
				
			||||||
            perror("File {} not exist, please check.", item);
 | 
					            mperror("File {} not exist, please check.", item);
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!fs::is_regular_file(item)) {
 | 
					        if (!fs::is_regular_file(item)) {
 | 
				
			||||||
            perror("Only Support Up File, But directory.", item);
 | 
					            mperror("Only Support Up File, But directory.", item);
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -198,7 +198,7 @@ bool CClient::up_task(const std::string& param)
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (msg.empty()) {
 | 
					    if (msg.empty()) {
 | 
				
			||||||
        pwarn("{} msg empty.", __FUNCTION__);
 | 
					        mpwarn("{} msg empty.", __FUNCTION__);
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -220,7 +220,7 @@ bool CClient::cancel_task()
 | 
				
			|||||||
        std::lock_guard<std::mutex> lock(mutex_);
 | 
					        std::lock_guard<std::mutex> lock(mutex_);
 | 
				
			||||||
        for (const auto& item : up_) {
 | 
					        for (const auto& item : up_) {
 | 
				
			||||||
            if (item.second->trans_state_ == TRANS_REDAY || item.second->trans_state_ == TRANS_ING) {
 | 
					            if (item.second->trans_state_ == TRANS_REDAY || item.second->trans_state_ == TRANS_ING) {
 | 
				
			||||||
                pwarn("Have Task Upping, Please wait!");
 | 
					                mpwarn("Have Task Upping, Please wait!");
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -247,10 +247,10 @@ bool CClient::down_one_file(const std::string& id, const std::string& file, cons
 | 
				
			|||||||
        down_->cur_file_ = fs::path(local_dir).append(remote_file.filename().string()).string();
 | 
					        down_->cur_file_ = fs::path(local_dir).append(remote_file.filename().string()).string();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pwarn("Start Down => {} To {}", down_->cur_remote_file_, down_->cur_file_);
 | 
					    mpwarn("Start Down => {} To {}", down_->cur_remote_file_, down_->cur_file_);
 | 
				
			||||||
    down_->file_.open(down_->cur_file_, std::ios::out | std::ios::binary);
 | 
					    down_->file_.open(down_->cur_file_, std::ios::out | std::ios::binary);
 | 
				
			||||||
    if (!down_->file_.is_open()) {
 | 
					    if (!down_->file_.is_open()) {
 | 
				
			||||||
        perror("Open {} Failed.", down_->cur_file_);
 | 
					        mperror("Open {} Failed.", down_->cur_file_);
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -261,7 +261,7 @@ bool CClient::down_one_file(const std::string& id, const std::string& file, cons
 | 
				
			|||||||
    buf->data_ = new char[file.size() + 1];
 | 
					    buf->data_ = new char[file.size() + 1];
 | 
				
			||||||
    buf->len_ = std::snprintf(buf->data_, file.size() + 1, "%s", file.data());
 | 
					    buf->len_ = std::snprintf(buf->data_, file.size() + 1, "%s", file.data());
 | 
				
			||||||
    if (!send_frame(buf.get())) {
 | 
					    if (!send_frame(buf.get())) {
 | 
				
			||||||
        perror("{} request open file [{}] send failed.", __FUNCTION__, down_->cur_remote_file_);
 | 
					        mperror("{} request open file [{}] send failed.", __FUNCTION__, down_->cur_remote_file_);
 | 
				
			||||||
        down_->cur_remote_id_.clear();
 | 
					        down_->cur_remote_id_.clear();
 | 
				
			||||||
        down_->cur_remote_file_.clear();
 | 
					        down_->cur_remote_file_.clear();
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
@ -277,7 +277,7 @@ bool CClient::down_one_file(const std::string& id, const std::string& file, cons
 | 
				
			|||||||
            CTransProtocal::display_progress(percent);
 | 
					            CTransProtocal::display_progress(percent);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (!th_run_) {
 | 
					        if (!th_run_) {
 | 
				
			||||||
            perror("Interrup When Receive File.");
 | 
					            mperror("Interrup When Receive File.");
 | 
				
			||||||
            report_trans_ret(TRANS_FAILED);
 | 
					            report_trans_ret(TRANS_FAILED);
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -287,10 +287,11 @@ bool CClient::down_one_file(const std::string& id, const std::string& file, cons
 | 
				
			|||||||
        CTransProtocal::display_progress(percent);
 | 
					        CTransProtocal::display_progress(percent);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (cur_file_size_ == cur_down_size_) {
 | 
					    if (cur_file_size_ == cur_down_size_) {
 | 
				
			||||||
        pwarn("Trans done, close file {}, total:[{}/{}]", down_->cur_file_, cur_down_size_, cur_file_size_);
 | 
					        mpwarn("Trans done, close file {}, total:[{}/{}]", down_->cur_file_, cur_down_size_, cur_file_size_);
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        pwarn("Trans failed, close file {}, total:[{}/{}]", down_->cur_file_, cur_down_size_, cur_file_size_);
 | 
					        mpwarn("Trans failed, close file {}, total:[{}/{}]", down_->cur_file_, cur_down_size_,
 | 
				
			||||||
 | 
					               cur_file_size_);
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -335,31 +336,31 @@ bool CClient::request_update_list(const std::string& param)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    auto tvec = COfStr::split(param, " ");
 | 
					    auto tvec = COfStr::split(param, " ");
 | 
				
			||||||
    if (tvec.size() < 2) {
 | 
					    if (tvec.size() < 2) {
 | 
				
			||||||
        perror("{} invalid param format [{}]", __FUNCTION__, param);
 | 
					        mperror("{} invalid param format [{}]", __FUNCTION__, param);
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    int index = std::stoi(tvec[0]);
 | 
					    int index = std::stoi(tvec[0]);
 | 
				
			||||||
    std::string list_file = tvec[1];
 | 
					    std::string list_file = tvec[1];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (downloading_) {
 | 
					    if (downloading_) {
 | 
				
			||||||
        pwarn("Have Task Downloading, Please wait.....");
 | 
					        mpwarn("Have Task Downloading, Please wait.....");
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (!task_list_.count(index)) {
 | 
					    if (!task_list_.count(index)) {
 | 
				
			||||||
        perror("No Index Found {}.", index);
 | 
					        mperror("No Index Found {}.", index);
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const auto& sr = task_list_[index];
 | 
					    const auto& sr = task_list_[index];
 | 
				
			||||||
    if (sr->id == own_id_) {
 | 
					    if (sr->id == own_id_) {
 | 
				
			||||||
        pwarn("You can't update your own file!!!");
 | 
					        mpwarn("You can't update your own file!!!");
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // 读取list文件
 | 
					    // 读取list文件
 | 
				
			||||||
    std::ifstream in(COfPath::to_full(list_file));
 | 
					    std::ifstream in(COfPath::to_full(list_file));
 | 
				
			||||||
    if (!in.is_open()) {
 | 
					    if (!in.is_open()) {
 | 
				
			||||||
        perror("Can't Open File:{}", COfPath::to_full(list_file));
 | 
					        mperror("Can't Open File:{}", COfPath::to_full(list_file));
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    std::istreambuf_iterator<char> iterf(in);
 | 
					    std::istreambuf_iterator<char> iterf(in);
 | 
				
			||||||
@ -376,11 +377,11 @@ bool CClient::request_update_list(const std::string& param)
 | 
				
			|||||||
        if (hitem.empty()) {
 | 
					        if (hitem.empty()) {
 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        pinfo("--->  check {}", hitem);
 | 
					        mpinfo("--->  check {}", hitem);
 | 
				
			||||||
        auto v = COfStr::split(hitem, "|");
 | 
					        auto v = COfStr::split(hitem, "|");
 | 
				
			||||||
        if (v.size() >= 2) {
 | 
					        if (v.size() >= 2) {
 | 
				
			||||||
            if (!fs::exists(v[0])) {
 | 
					            if (!fs::exists(v[0])) {
 | 
				
			||||||
                perror("file {} not exist.", v[0]);
 | 
					                mperror("file {} not exist.", v[0]);
 | 
				
			||||||
                valid = false;
 | 
					                valid = false;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -392,7 +393,7 @@ bool CClient::request_update_list(const std::string& param)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!valid) {
 | 
					    if (!valid) {
 | 
				
			||||||
        perror("Judge List File {} Format Not Passed.", list_file);
 | 
					        mperror("Judge List File {} Format Not Passed.", list_file);
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -404,7 +405,7 @@ bool CClient::request_update_list(const std::string& param)
 | 
				
			|||||||
    buf->tid_ = task_list_[index]->id;
 | 
					    buf->tid_ = task_list_[index]->id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!send_frame(buf.get())) {
 | 
					    if (!send_frame(buf.get())) {
 | 
				
			||||||
        perror("Send Failed {}", __LINE__);
 | 
					        mperror("Send Failed {}", __LINE__);
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
@ -420,13 +421,13 @@ bool CClient::check_update_list(const std::string& content, std::map<std::string
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        auto vi = COfStr::split(item, "|");
 | 
					        auto vi = COfStr::split(item, "|");
 | 
				
			||||||
        if (vi.size() != 2) {
 | 
					        if (vi.size() != 2) {
 | 
				
			||||||
            perror("Size not 2 {}", item);
 | 
					            mperror("Size not 2 {}", item);
 | 
				
			||||||
            valid = true;
 | 
					            valid = true;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (!fs::exists(vi[1])) {
 | 
					        if (!fs::exists(vi[1])) {
 | 
				
			||||||
            valid = false;
 | 
					            valid = false;
 | 
				
			||||||
            perror("Not exist {}", vi[1]);
 | 
					            mperror("Not exist {}", vi[1]);
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        files[vi[0]] = vi[1];
 | 
					        files[vi[0]] = vi[1];
 | 
				
			||||||
@ -448,10 +449,10 @@ bool CClient::down_update_file(std::map<std::string, std::string> files)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    if (suc) {
 | 
					    if (suc) {
 | 
				
			||||||
        buf->type_ = TYPE_DONE_UPDATE_LIST;
 | 
					        buf->type_ = TYPE_DONE_UPDATE_LIST;
 | 
				
			||||||
        pinfo("Do Task From {} Done!", buf->tid_);
 | 
					        mpinfo("Do Task From {} Done!", buf->tid_);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        buf->type_ = TYPE_FAILED_UPDATE_LIST;
 | 
					        buf->type_ = TYPE_FAILED_UPDATE_LIST;
 | 
				
			||||||
        pinfo("Do Task From {} Failed!", buf->tid_);
 | 
					        mpinfo("Do Task From {} Failed!", buf->tid_);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    send_frame(buf.get());
 | 
					    send_frame(buf.get());
 | 
				
			||||||
    return suc;
 | 
					    return suc;
 | 
				
			||||||
@ -462,7 +463,7 @@ bool CClient::send_frame(CFrameBuffer* buf)
 | 
				
			|||||||
    char* out_buf{};
 | 
					    char* out_buf{};
 | 
				
			||||||
    int out_len{};
 | 
					    int out_len{};
 | 
				
			||||||
    if (!CTransProtocal::pack(buf, &out_buf, out_len)) {
 | 
					    if (!CTransProtocal::pack(buf, &out_buf, out_len)) {
 | 
				
			||||||
        perror("{} pack failed.", __FUNCTION__);
 | 
					        mperror("{} pack failed.", __FUNCTION__);
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    std::lock_guard<std::mutex> lock(send_mut_);
 | 
					    std::lock_guard<std::mutex> lock(send_mut_);
 | 
				
			||||||
@ -477,12 +478,12 @@ bool CClient::send_frame(CFrameBuffer* buf)
 | 
				
			|||||||
void CClient::handle_frame(CFrameBuffer* buf)
 | 
					void CClient::handle_frame(CFrameBuffer* buf)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (buf == nullptr) {
 | 
					    if (buf == nullptr) {
 | 
				
			||||||
        perror("{} nullptr.", __FUNCTION__);
 | 
					        mperror("{} nullptr.", __FUNCTION__);
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    switch (buf->type_) {
 | 
					    switch (buf->type_) {
 | 
				
			||||||
    case TYPE_GET_ID: {
 | 
					    case TYPE_GET_ID: {
 | 
				
			||||||
        pdebug("Your ID:{}", buf->tid_);
 | 
					        mpdebug("Your ID:{}", buf->tid_);
 | 
				
			||||||
        own_id_ = buf->tid_;
 | 
					        own_id_ = buf->tid_;
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -498,9 +499,9 @@ void CClient::handle_frame(CFrameBuffer* buf)
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            if (real.find("[") == std::string::npos) {
 | 
					            if (real.find("[") == std::string::npos) {
 | 
				
			||||||
#ifdef _WIN32
 | 
					#ifdef _WIN32
 | 
				
			||||||
                pinfo("FILE ==> {}", CCodec::u8_to_ansi(real));
 | 
					                mpinfo("FILE ==> {}", CCodec::u8_to_ansi(real));
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
                pinfo("FILE ==> {}", real);
 | 
					                mpinfo("FILE ==> {}", real);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
                task_list_[index]->files.push_back(real);
 | 
					                task_list_[index]->files.push_back(real);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
@ -520,8 +521,8 @@ void CClient::handle_frame(CFrameBuffer* buf)
 | 
				
			|||||||
                    task_list_[index]->id = id;
 | 
					                    task_list_[index]->id = id;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                pdebug("*****************************************");
 | 
					                mpdebug("*****************************************");
 | 
				
			||||||
                pinfo("{}", real);
 | 
					                mpinfo("{}", real);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
@ -536,7 +537,7 @@ void CClient::handle_frame(CFrameBuffer* buf)
 | 
				
			|||||||
            down_->file_.write(buf->data_, buf->len_);
 | 
					            down_->file_.write(buf->data_, buf->len_);
 | 
				
			||||||
            if (down_->file_.fail()) {
 | 
					            if (down_->file_.fail()) {
 | 
				
			||||||
                report_trans_ret(TRANS_FAILED);
 | 
					                report_trans_ret(TRANS_FAILED);
 | 
				
			||||||
                pwarn("no matched write and data. {}", buf->len_);
 | 
					                mpwarn("no matched write and data. {}", buf->len_);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            cur_down_size_ += buf->len_;
 | 
					            cur_down_size_ += buf->len_;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -555,7 +556,7 @@ void CClient::handle_frame(CFrameBuffer* buf)
 | 
				
			|||||||
            up_[buf->fid_]->file_.open(up_[buf->fid_]->cur_file_, std::ios::in | std::ios::binary);
 | 
					            up_[buf->fid_]->file_.open(up_[buf->fid_]->cur_file_, std::ios::in | std::ios::binary);
 | 
				
			||||||
            up_[buf->fid_]->trans_state_ = TRANS_REDAY;
 | 
					            up_[buf->fid_]->trans_state_ = TRANS_REDAY;
 | 
				
			||||||
            if (!up_[buf->fid_]->file_.is_open()) {
 | 
					            if (!up_[buf->fid_]->file_.is_open()) {
 | 
				
			||||||
                perror("Ready Send File {} Open Failed.", up_[buf->fid_]->cur_file_);
 | 
					                mperror("Ready Send File {} Open Failed.", up_[buf->fid_]->cur_file_);
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            keys = buf->fid_;
 | 
					            keys = buf->fid_;
 | 
				
			||||||
@ -573,7 +574,7 @@ void CClient::handle_frame(CFrameBuffer* buf)
 | 
				
			|||||||
        if (buf->mark_) {
 | 
					        if (buf->mark_) {
 | 
				
			||||||
            std::lock_guard<std::mutex> lock(mutex_);
 | 
					            std::lock_guard<std::mutex> lock(mutex_);
 | 
				
			||||||
            if (!up_.count(buf->fid_)) {
 | 
					            if (!up_.count(buf->fid_)) {
 | 
				
			||||||
                pwarn("Offline no match.");
 | 
					                mpwarn("Offline no match.");
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            auto t = up_[buf->fid_];
 | 
					            auto t = up_[buf->fid_];
 | 
				
			||||||
@ -581,7 +582,7 @@ void CClient::handle_frame(CFrameBuffer* buf)
 | 
				
			|||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (downloading_ && !down_->cur_remote_file_.empty()) {
 | 
					        if (downloading_ && !down_->cur_remote_file_.empty()) {
 | 
				
			||||||
            pwarn("Stop Down {} From {}.", down_->cur_remote_file_, buf->fid_);
 | 
					            mpwarn("Stop Down {} From {}.", down_->cur_remote_file_, buf->fid_);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        report_trans_ret(TRANS_FAILED);
 | 
					        report_trans_ret(TRANS_FAILED);
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
@ -597,14 +598,14 @@ void CClient::handle_frame(CFrameBuffer* buf)
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        std::swap(buf->tid_, buf->fid_);
 | 
					        std::swap(buf->tid_, buf->fid_);
 | 
				
			||||||
        if (!send_frame(buf)) {
 | 
					        if (!send_frame(buf)) {
 | 
				
			||||||
            perror("Send Failed {}.", __LINE__);
 | 
					            mperror("Send Failed {}.", __LINE__);
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (buf->type_ == TYPE_UNCONFIRM_UPDATE_LIST) {
 | 
					        if (buf->type_ == TYPE_UNCONFIRM_UPDATE_LIST) {
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        list_serve_id_ = buf->tid_;
 | 
					        list_serve_id_ = buf->tid_;
 | 
				
			||||||
        pdebug("Do Task From {}.", buf->tid_);
 | 
					        mpdebug("Do Task From {}.", buf->tid_);
 | 
				
			||||||
        if (update_list_th_.joinable()) {
 | 
					        if (update_list_th_.joinable()) {
 | 
				
			||||||
            update_list_th_.join();
 | 
					            update_list_th_.join();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -612,26 +613,26 @@ void CClient::handle_frame(CFrameBuffer* buf)
 | 
				
			|||||||
        break;
 | 
					        break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    case TYPE_CONFIRM_UPDATE_LIST: {
 | 
					    case TYPE_CONFIRM_UPDATE_LIST: {
 | 
				
			||||||
        pinfo("remote {} check {} passed!", buf->fid_, list_file_);
 | 
					        mpinfo("remote {} check {} passed!", buf->fid_, list_file_);
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    case TYPE_UNCONFIRM_UPDATE_LIST: {
 | 
					    case TYPE_UNCONFIRM_UPDATE_LIST: {
 | 
				
			||||||
        perror("remote {} check {} not passed!", buf->fid_, list_file_);
 | 
					        mperror("remote {} check {} not passed!", buf->fid_, list_file_);
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    case TYPE_DONE_UPDATE_LIST: {
 | 
					    case TYPE_DONE_UPDATE_LIST: {
 | 
				
			||||||
        pinfo("remote {} do task {} success!", buf->fid_, list_file_);
 | 
					        mpinfo("remote {} do task {} success!", buf->fid_, list_file_);
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    case TYPE_FAILED_UPDATE_LIST: {
 | 
					    case TYPE_FAILED_UPDATE_LIST: {
 | 
				
			||||||
        pinfo("remote {} do task {} failed!", buf->fid_, list_file_);
 | 
					        mpinfo("remote {} do task {} failed!", buf->fid_, list_file_);
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    case TYPE_FILE_SIZE: {
 | 
					    case TYPE_FILE_SIZE: {
 | 
				
			||||||
        std::string str_size(buf->data_, buf->len_);
 | 
					        std::string str_size(buf->data_, buf->len_);
 | 
				
			||||||
        long long size = std::stoll(str_size);
 | 
					        long long size = std::stoll(str_size);
 | 
				
			||||||
        std::string show_str = OfUtil::get_file_size(size);
 | 
					        std::string show_str = OfUtil::get_file_size(size);
 | 
				
			||||||
        pinfo("Ready Down Size: {}", show_str);
 | 
					        mpinfo("Ready Down Size: {}", show_str);
 | 
				
			||||||
        cur_file_size_ = size;
 | 
					        cur_file_size_ = size;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    default:
 | 
					    default:
 | 
				
			||||||
@ -647,13 +648,13 @@ void CClient::send_file_data_th(const char* keys)
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        std::lock_guard<std::mutex> lock(mutex_);
 | 
					        std::lock_guard<std::mutex> lock(mutex_);
 | 
				
			||||||
        if (!up_.count(str_key)) {
 | 
					        if (!up_.count(str_key)) {
 | 
				
			||||||
            perror("{} no matched key.", __FUNCTION__);
 | 
					            mperror("{} no matched key.", __FUNCTION__);
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        t = up_[str_key];
 | 
					        t = up_[str_key];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pinfo("Start Trans File {} To {}", t->cur_file_, str_key);
 | 
					    mpinfo("Start Trans File {} To {}", t->cur_file_, str_key);
 | 
				
			||||||
    std::shared_ptr<CFrameBuffer> buf = std::make_shared<CFrameBuffer>();
 | 
					    std::shared_ptr<CFrameBuffer> buf = std::make_shared<CFrameBuffer>();
 | 
				
			||||||
    buf->data_ = new char[g_BuffSize]{};
 | 
					    buf->data_ = new char[g_BuffSize]{};
 | 
				
			||||||
    buf->tid_ = str_key;
 | 
					    buf->tid_ = str_key;
 | 
				
			||||||
@ -665,11 +666,11 @@ void CClient::send_file_data_th(const char* keys)
 | 
				
			|||||||
    buf->type_ = TYPE_FILE_SIZE;
 | 
					    buf->type_ = TYPE_FILE_SIZE;
 | 
				
			||||||
    std::string str_size = std::to_string(size);
 | 
					    std::string str_size = std::to_string(size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pinfo("To {} File Size: {} [{}]", str_key, ofen::OfUtil::get_file_size(size), size);
 | 
					    mpinfo("To {} File Size: {} [{}]", str_key, ofen::OfUtil::get_file_size(size), size);
 | 
				
			||||||
    buf->len_ = std::snprintf(buf->data_, g_BuffSize, "%s", str_size.c_str());
 | 
					    buf->len_ = std::snprintf(buf->data_, g_BuffSize, "%s", str_size.c_str());
 | 
				
			||||||
    if (!send_frame(buf.get())) {
 | 
					    if (!send_frame(buf.get())) {
 | 
				
			||||||
        report_trans_ret(TRANS_FAILED, str_key);
 | 
					        report_trans_ret(TRANS_FAILED, str_key);
 | 
				
			||||||
        perror("Stop Trans {} To {} failed.", t->cur_file_, str_key);
 | 
					        mperror("Stop Trans {} To {} failed.", t->cur_file_, str_key);
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    buf->type_ = TYPE_TRANS_FILE;
 | 
					    buf->type_ = TYPE_TRANS_FILE;
 | 
				
			||||||
@ -677,7 +678,7 @@ void CClient::send_file_data_th(const char* keys)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    while (!t->file_.eof()) {
 | 
					    while (!t->file_.eof()) {
 | 
				
			||||||
        if (t->trans_state_ == TRANS_BREAK) {
 | 
					        if (t->trans_state_ == TRANS_BREAK) {
 | 
				
			||||||
            pwarn("Stop Trans {} To {} failed.", t->cur_file_, str_key);
 | 
					            mpwarn("Stop Trans {} To {} failed.", t->cur_file_, str_key);
 | 
				
			||||||
            report_trans_ret(TRANS_FAILED, str_key);
 | 
					            report_trans_ret(TRANS_FAILED, str_key);
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -685,7 +686,7 @@ void CClient::send_file_data_th(const char* keys)
 | 
				
			|||||||
        buf->len_ = t->file_.gcount();
 | 
					        buf->len_ = t->file_.gcount();
 | 
				
			||||||
        if (!send_frame(buf.get())) {
 | 
					        if (!send_frame(buf.get())) {
 | 
				
			||||||
            report_trans_ret(TRANS_FAILED, str_key);
 | 
					            report_trans_ret(TRANS_FAILED, str_key);
 | 
				
			||||||
            perror("Stop Trans {} To {} failed.", t->cur_file_, str_key);
 | 
					            mperror("Stop Trans {} To {} failed.", t->cur_file_, str_key);
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // std::this_thread::sleep_for(std::chrono::milliseconds(10));
 | 
					        // std::this_thread::sleep_for(std::chrono::milliseconds(10));
 | 
				
			||||||
@ -693,10 +694,10 @@ void CClient::send_file_data_th(const char* keys)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    buf->type_ = TYPE_TRANS_DONE;
 | 
					    buf->type_ = TYPE_TRANS_DONE;
 | 
				
			||||||
    if (!send_frame(buf.get())) {
 | 
					    if (!send_frame(buf.get())) {
 | 
				
			||||||
        perror("send_file_data_th send DONE failed.");
 | 
					        mperror("send_file_data_th send DONE failed.");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    report_trans_ret(TRANS_DONE, str_key);
 | 
					    report_trans_ret(TRANS_DONE, str_key);
 | 
				
			||||||
    pdebug("Trans File {} To {} Done !!!", t->cur_file_, str_key);
 | 
					    mpdebug("Trans File {} To {} Done !!!", t->cur_file_, str_key);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void CClient::hearts()
 | 
					void CClient::hearts()
 | 
				
			||||||
@ -706,7 +707,7 @@ void CClient::hearts()
 | 
				
			|||||||
    while (th_run_) {
 | 
					    while (th_run_) {
 | 
				
			||||||
        sleep_.sleep();
 | 
					        sleep_.sleep();
 | 
				
			||||||
        if (th_run_ && !send_frame(buf.get())) {
 | 
					        if (th_run_ && !send_frame(buf.get())) {
 | 
				
			||||||
            perror("{} send failed.", __FUNCTION__);
 | 
					            mperror("{} send failed.", __FUNCTION__);
 | 
				
			||||||
            th_run_ = false;
 | 
					            th_run_ = false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -26,7 +26,7 @@ bool CServerConfig::baseInit()
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    SI_Error ret = ini_handle_.LoadFile(config_path_.c_str());
 | 
					    SI_Error ret = ini_handle_.LoadFile(config_path_.c_str());
 | 
				
			||||||
    if (ret != SI_OK) {
 | 
					    if (ret != SI_OK) {
 | 
				
			||||||
        perror("Load Ini [{}] Failed.", config_path_);
 | 
					        mperror("Load Ini [{}] Failed.", config_path_);
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    init_ = true;
 | 
					    init_ = true;
 | 
				
			||||||
@ -38,7 +38,7 @@ bool CServerConfig::read_ini(std::vector<TransmSet>& set)
 | 
				
			|||||||
    assert(init_ == true);
 | 
					    assert(init_ == true);
 | 
				
			||||||
    long groups = ini_handle_.GetLongValue("BASE", "GROUPS");
 | 
					    long groups = ini_handle_.GetLongValue("BASE", "GROUPS");
 | 
				
			||||||
    if (groups < 1) {
 | 
					    if (groups < 1) {
 | 
				
			||||||
        perror("GROUPS num < 1.");
 | 
					        mperror("GROUPS num < 1.");
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    set.clear();
 | 
					    set.clear();
 | 
				
			||||||
@ -108,7 +108,7 @@ bool CServerConfig::get_ini(const std::vector<TransmSet>& set, long num, TransmS
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void CServerConfig::gen_default_ini(const std::string& path)
 | 
					void CServerConfig::gen_default_ini(const std::string& path)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    pwarn("Gen Default Setting Ini in [{}].", path);
 | 
					    mpwarn("Gen Default Setting Ini in [{}].", path);
 | 
				
			||||||
    ini_handle_.LoadFile(path.c_str());
 | 
					    ini_handle_.LoadFile(path.c_str());
 | 
				
			||||||
    ini_handle_.SetLongValue("BASE", "GROUPS", 1);
 | 
					    ini_handle_.SetLongValue("BASE", "GROUPS", 1);
 | 
				
			||||||
    ini_handle_.SetValue("GROUP0", "IP", "127.0.0.1");
 | 
					    ini_handle_.SetValue("GROUP0", "IP", "127.0.0.1");
 | 
				
			||||||
 | 
				
			|||||||
@ -52,7 +52,7 @@ bool exec_cmd(const CmdParam& param, bool& run)
 | 
				
			|||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        for (const auto& item : set) {
 | 
					        for (const auto& item : set) {
 | 
				
			||||||
            pinfo("{} => {}:{}", item.group, item.ip, item.port);
 | 
					            mpinfo("{} => {}:{}", item.group, item.ip, item.port);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -61,34 +61,34 @@ bool exec_cmd(const CmdParam& param, bool& run)
 | 
				
			|||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (!param.appendValue.empty() && !param.removeValue.empty()) {
 | 
					    if (!param.appendValue.empty() && !param.removeValue.empty()) {
 | 
				
			||||||
        perror("append and remove can't simultaneous operate!");
 | 
					        mperror("append and remove can't simultaneous operate!");
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (!param.appendValue.empty()) {
 | 
					    if (!param.appendValue.empty()) {
 | 
				
			||||||
        std::regex rg(R"(([^:]+):(\d+))");
 | 
					        std::regex rg(R"(([^:]+):(\d+))");
 | 
				
			||||||
        std::smatch match;
 | 
					        std::smatch match;
 | 
				
			||||||
        if (!std::regex_search(param.appendValue, match, rg)) {
 | 
					        if (!std::regex_search(param.appendValue, match, rg)) {
 | 
				
			||||||
            perror("append invalid format!");
 | 
					            mperror("append invalid format!");
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        std::string ip = match[1].str();
 | 
					        std::string ip = match[1].str();
 | 
				
			||||||
        std::string port = match[2].str();
 | 
					        std::string port = match[2].str();
 | 
				
			||||||
        if (!g_Config->append_ini(ip, std::stol(port))) {
 | 
					        if (!g_Config->append_ini(ip, std::stol(port))) {
 | 
				
			||||||
            perror("add {}:{} failed.", ip, port);
 | 
					            mperror("add {}:{} failed.", ip, port);
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        pinfo("add {}:{} success.", ip, port);
 | 
					        mpinfo("add {}:{} success.", ip, port);
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (!param.removeValue.empty()) {
 | 
					    if (!param.removeValue.empty()) {
 | 
				
			||||||
        if (!g_Config->remove_ini(std::stol(param.removeValue))) {
 | 
					        if (!g_Config->remove_ini(std::stol(param.removeValue))) {
 | 
				
			||||||
            perror("remove config num=[{}] failed, please check!", param.removeValue);
 | 
					            mperror("remove config num=[{}] failed, please check!", param.removeValue);
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        pinfo("remove config num=[{}] success!", param.removeValue);
 | 
					        mpinfo("remove config num=[{}] success!", param.removeValue);
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    perror("not matched!", param.removeValue);
 | 
					    mperror("not matched!", param.removeValue);
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -115,7 +115,7 @@ int main(int argc, char* argv[])
 | 
				
			|||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (!exec_cmd(param, run)) {
 | 
					    if (!exec_cmd(param, run)) {
 | 
				
			||||||
        perror("exec_cmd failed!");
 | 
					        mperror("exec_cmd failed!");
 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (!run) {
 | 
					    if (!run) {
 | 
				
			||||||
@ -128,13 +128,13 @@ int main(int argc, char* argv[])
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    TransmSet use;
 | 
					    TransmSet use;
 | 
				
			||||||
    if (!g_Config->get_ini(set, param.use_config, use)) {
 | 
					    if (!g_Config->get_ini(set, param.use_config, use)) {
 | 
				
			||||||
        perror("Not found config by num:[{}]", param.use_config);
 | 
					        mperror("Not found config by num:[{}]", param.use_config);
 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    pinfo("Build At {} {} under {} on {}", __DATE__, __TIME__, VERSION_GIT_COMMIT, VERSION_GIT_BRANCH);
 | 
					    mpinfo("Build At {} {} under {} on {}", __DATE__, __TIME__, VERSION_GIT_COMMIT, VERSION_GIT_BRANCH);
 | 
				
			||||||
    pinfo("use ip => [{}], port => [{}]", use.ip, use.port);
 | 
					    mpinfo("use ip => [{}], port => [{}]", use.ip, use.port);
 | 
				
			||||||
    CClient client;
 | 
					    CClient client;
 | 
				
			||||||
    client.run(use.ip, std::to_string(use.port));
 | 
					    client.run(use.ip, std::to_string(use.port));
 | 
				
			||||||
    pinfo("exit ==========");
 | 
					    mpinfo("exit ==========");
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -14,11 +14,11 @@ bool CTcpClient::connect(const std::string& host, const std::string& port)
 | 
				
			|||||||
        asio::ip::tcp::resolver resolver(io_context_);
 | 
					        asio::ip::tcp::resolver resolver(io_context_);
 | 
				
			||||||
        asio::ip::tcp::resolver::results_type endpoints = resolver.resolve(host, port);
 | 
					        asio::ip::tcp::resolver::results_type endpoints = resolver.resolve(host, port);
 | 
				
			||||||
        asio::connect(socket_, endpoints);
 | 
					        asio::connect(socket_, endpoints);
 | 
				
			||||||
        pinfo("Connected to {}:{}", host, port);
 | 
					        mpinfo("Connected to {}:{}", host, port);
 | 
				
			||||||
        is_normal_ = true;
 | 
					        is_normal_ = true;
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    } catch (const std::exception& ex) {
 | 
					    } catch (const std::exception& ex) {
 | 
				
			||||||
        perror("Connection failed: {}", ex.what());
 | 
					        mperror("Connection failed: {}", ex.what());
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -29,9 +29,9 @@ void CTcpClient::disconnect()
 | 
				
			|||||||
        try {
 | 
					        try {
 | 
				
			||||||
            socket_.shutdown(asio::ip::tcp::socket::shutdown_both);
 | 
					            socket_.shutdown(asio::ip::tcp::socket::shutdown_both);
 | 
				
			||||||
            socket_.close();
 | 
					            socket_.close();
 | 
				
			||||||
            pinfo("Disconnected.");
 | 
					            mpinfo("Disconnected.");
 | 
				
			||||||
        } catch (const std::exception& ex) {
 | 
					        } catch (const std::exception& ex) {
 | 
				
			||||||
            perror("Error during disconnection: {}", ex.what());
 | 
					            mperror("Error during disconnection: {}", ex.what());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -39,15 +39,15 @@ void CTcpClient::disconnect()
 | 
				
			|||||||
bool CTcpClient::send(const char* data, int len)
 | 
					bool CTcpClient::send(const char* data, int len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (!is_normal_) {
 | 
					    if (!is_normal_) {
 | 
				
			||||||
        perror("abnormal state, will not send.");
 | 
					        mperror("abnormal state, will not send.");
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
        auto send_size = asio::write(socket_, asio::buffer(data, len));
 | 
					        auto send_size = asio::write(socket_, asio::buffer(data, len));
 | 
				
			||||||
        // pinfo("Need Send len: {} Real Send len: {}", len, send_size);
 | 
					        // mpinfo("Need Send len: {} Real Send len: {}", len, send_size);
 | 
				
			||||||
        return static_cast<int>(send_size) == len;
 | 
					        return static_cast<int>(send_size) == len;
 | 
				
			||||||
    } catch (const std::exception& ex) {
 | 
					    } catch (const std::exception& ex) {
 | 
				
			||||||
        perror("Send failed: {}", ex.what());
 | 
					        mperror("Send failed: {}", ex.what());
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -68,10 +68,10 @@ void CTcpClient::async_recv()
 | 
				
			|||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (ec.value() == 125) {
 | 
					            if (ec.value() == 125) {
 | 
				
			||||||
                pinfo("{} exit.", __FUNCTION__);
 | 
					                mpinfo("{} exit.", __FUNCTION__);
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            perror("{} {} error => {}", __FUNCTION__, ec.value(), ec.message());
 | 
					            mperror("{} {} error => {}", __FUNCTION__, ec.value(), ec.message());
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            buffer_.push(tmp_buf_.data(), length);
 | 
					            buffer_.push(tmp_buf_.data(), length);
 | 
				
			||||||
            while (true) {
 | 
					            while (true) {
 | 
				
			||||||
 | 
				
			|||||||
@ -93,19 +93,19 @@ inline std::string now_str()
 | 
				
			|||||||
    return timestamp.str();
 | 
					    return timestamp.str();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template <typename... Args> void pdebug(const std::string& format, Args&&... args)
 | 
					template <typename... Args> void mpdebug(const std::string& format, Args&&... args)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    fmt::print(fg(fmt::color::steel_blue), now_str() + format + "\n", std::forward<Args>(args)...);
 | 
					    fmt::print(fg(fmt::color::steel_blue), now_str() + format + "\n", std::forward<Args>(args)...);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
template <typename... Args> void pinfo(const std::string& format, Args&&... args)
 | 
					template <typename... Args> void mpinfo(const std::string& format, Args&&... args)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    fmt::print(fg(fmt::color::gray), now_str() + format + "\n", std::forward<Args>(args)...);
 | 
					    fmt::print(fg(fmt::color::gray), now_str() + format + "\n", std::forward<Args>(args)...);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
template <typename... Args> void pwarn(const std::string& format, Args&&... args)
 | 
					template <typename... Args> void mpwarn(const std::string& format, Args&&... args)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    fmt::print(fg(fmt::color::yellow_green), now_str() + format + "\n", std::forward<Args>(args)...);
 | 
					    fmt::print(fg(fmt::color::yellow_green), now_str() + format + "\n", std::forward<Args>(args)...);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
template <typename... Args> void perror(const std::string& format, Args&&... args)
 | 
					template <typename... Args> void mperror(const std::string& format, Args&&... args)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    fmt::print(fg(fmt::color::orange_red), now_str() + format + "\n", std::forward<Args>(args)...);
 | 
					    fmt::print(fg(fmt::color::orange_red), now_str() + format + "\n", std::forward<Args>(args)...);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user