From 1dbe46cd9d0f181d08d5a69f72d8548628a13b9d Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期三, 16 七月 2025 17:13:50 +0800
Subject: [PATCH] 优化:显示在流程中解锁,并且把文件字符集统一替换成UTF-8(BOM)

---
 EdgeInspector_App/WebSocket/WebSocketClientPool.cpp |  122 ++++++++++++++++++++--------------------
 1 files changed, 61 insertions(+), 61 deletions(-)

diff --git a/EdgeInspector_App/WebSocket/WebSocketClientPool.cpp b/EdgeInspector_App/WebSocket/WebSocketClientPool.cpp
index ebd36c4..96418f6 100644
--- a/EdgeInspector_App/WebSocket/WebSocketClientPool.cpp
+++ b/EdgeInspector_App/WebSocket/WebSocketClientPool.cpp
@@ -1,4 +1,4 @@
-#include "StdAfx.h"
+锘�#include "StdAfx.h"
 #include "WebSocketClientPool.h"
 
 //WebSocketClientPool::WebSocketClientPool(size_t thread_count) : m_thread_pool(thread_count) {}
@@ -33,7 +33,7 @@
 //        }
 //	}
 //
-//    // 清空之前的客户端,确保是干净的状态
+//    // 娓呯┖涔嬪墠鐨勫鎴风锛岀‘淇濇槸骞插噣鐨勭姸鎬�
 //    m_clients.clear();
 //}
 //
@@ -62,148 +62,148 @@
 //bool WebSocketClientPool::post_to_idle_client(const std::string& message) {
 //    for (auto& client : m_clients) {
 //        if (client->is_connected()) {
-//            // 提交发送任务到线程池
+//            // 鎻愪氦鍙戦�佷换鍔″埌绾跨▼姹�
 //            m_thread_pool.enqueue([client, message]() {
-//                client->set_busy(true);   // 标记为忙碌
-//                client->send(message);    // 发送消息
-//                client->set_busy(false);  // 完成后标记为空闲
+//                client->set_busy(true);   // 鏍囪涓哄繖纰�
+//                client->send(message);    // 鍙戦�佹秷鎭�
+//                client->set_busy(false);  // 瀹屾垚鍚庢爣璁颁负绌洪棽
 //            });
-//            return true; // 成功提交任务
+//            return true; // 鎴愬姛鎻愪氦浠诲姟
 //        }
 //    }
-//    return false; // 没有可用客户端
+//    return false; // 娌℃湁鍙敤瀹㈡埛绔�
 //}
 //
 //bool WebSocketClientPool::post_binary_to_idle_client(const std::vector<char>& binary_data) {
 //    for (auto& client : m_clients) {
 //        if (client->is_connected()) {
-//            // 提交发送任务到线程池
+//            // 鎻愪氦鍙戦�佷换鍔″埌绾跨▼姹�
 //            m_thread_pool.enqueue([client, binary_data]() {
-//                client->set_busy(true);   // 标记为忙碌
-//                client->send_binary(binary_data); // 发送二进制数据
-//                client->set_busy(false);  // 完成后标记为空闲
+//                client->set_busy(true);   // 鏍囪涓哄繖纰�
+//                client->send_binary(binary_data); // 鍙戦�佷簩杩涘埗鏁版嵁
+//                client->set_busy(false);  // 瀹屾垚鍚庢爣璁颁负绌洪棽
 //            });
-//            return true; // 成功提交任务
+//            return true; // 鎴愬姛鎻愪氦浠诲姟
 //        }
 //    }
-//    return false; // 没有可用客户端
+//    return false; // 娌℃湁鍙敤瀹㈡埛绔�
 //}
 //
 //bool WebSocketClientPool::send_to_idle_client(const std::string& message, int timeout_ms) {
 //    for (auto& client : m_clients) {
 //        if (!client->is_busy() && client->is_connected()) {
-//            // 标记为忙
+//            // 鏍囪涓哄繖
 //            client->set_busy(true);
 //
-//            // 使用线程池发送消息
+//            // 浣跨敤绾跨▼姹犲彂閫佹秷鎭�
 //            m_thread_pool.enqueue([client, message, timeout_ms]() {
-//                // 发送消息并等待服务器回复
-//                client->send_and_wait(message, timeout_ms); // 5秒超时
-//                client->set_busy(false); // 标记为空闲
+//                // 鍙戦�佹秷鎭苟绛夊緟鏈嶅姟鍣ㄥ洖澶�
+//                client->send_and_wait(message, timeout_ms); // 5绉掕秴鏃�
+//                client->set_busy(false); // 鏍囪涓虹┖闂�
 //            });
 //
-//            return true; // 成功发送消息,返回 true
+//            return true; // 鎴愬姛鍙戦�佹秷鎭紝杩斿洖 true
 //        }
 //    }
-//    return false; // 没有空闲客户端
+//    return false; // 娌℃湁绌洪棽瀹㈡埛绔�
 //}
 //
 //bool WebSocketClientPool::send_binary_to_idle_client(const std::vector<char>& binary_data, int timeout_ms) {
 //    for (auto& client : m_clients) {
 //        if (!client->is_busy() && client->is_connected()) {
-//            // 标记为忙
+//            // 鏍囪涓哄繖
 //            client->set_busy(true);
 //
-//            // 使用线程池发送消息
+//            // 浣跨敤绾跨▼姹犲彂閫佹秷鎭�
 //            m_thread_pool.enqueue([client, binary_data, timeout_ms]() {
-//                // 发送消息并等待服务器回复
+//                // 鍙戦�佹秷鎭苟绛夊緟鏈嶅姟鍣ㄥ洖澶�
 //                client->send_binary_and_wait(binary_data, timeout_ms);
-//                client->set_busy(false); // 标记为空闲
+//                client->set_busy(false); // 鏍囪涓虹┖闂�
 //            });
 //
-//            return true; // 成功发送消息,返回 true
+//            return true; // 鎴愬姛鍙戦�佹秷鎭紝杩斿洖 true
 //        }
 //    }
-//    return false; // 没有空闲客户端
+//    return false; // 娌℃湁绌洪棽瀹㈡埛绔�
 //}
 //
 //bool WebSocketClientPool::send_to_idle_client_and_wait(const std::string& message, int timeout_ms) {
 //    for (auto& client : m_clients) {
 //        if (!client->is_busy() && client->is_connected()) {
-//            client->set_busy(true); // 标记为忙
+//            client->set_busy(true); // 鏍囪涓哄繖
 //
 //            try {
-//                // 直接在当前线程调用 send_and_wait,阻塞直到任务完成
+//                // 鐩存帴鍦ㄥ綋鍓嶇嚎绋嬭皟鐢� send_and_wait锛岄樆濉炵洿鍒颁换鍔″畬鎴�
 //                bool result = client->send_and_wait(message, timeout_ms);
-//                client->set_busy(false); // 设置为空闲状态
-//                return result; // 返回结果
+//                client->set_busy(false); // 璁剧疆涓虹┖闂茬姸鎬�
+//                return result; // 杩斿洖缁撴灉
 //            }
 //            catch (const std::exception& e) {
 //                std::cerr << "Exception during sending: " << e.what() << std::endl;
-//                client->set_busy(false); // 即使发生异常,也要重置为未忙状态
-//                return false; // 发生异常,返回失败
+//                client->set_busy(false); // 鍗充娇鍙戠敓寮傚父锛屼篃瑕侀噸缃负鏈繖鐘舵��
+//                return false; // 鍙戠敓寮傚父锛岃繑鍥炲け璐�
 //            }
 //        }
 //    }
-//    return false; // 没有空闲客户端
+//    return false; // 娌℃湁绌洪棽瀹㈡埛绔�
 //}
 //
 //bool WebSocketClientPool::send_binary_to_idle_client_and_wait(const std::vector<char>& binary_data, int timeout_ms) {
 //    for (auto& client : m_clients) {
 //        if (!client->is_busy() && client->is_connected()) {
-//            client->set_busy(true); // 标记为忙
+//            client->set_busy(true); // 鏍囪涓哄繖
 //
 //            try {
-//                // 直接在当前线程调用 send_and_wait,阻塞直到任务完成
+//                // 鐩存帴鍦ㄥ綋鍓嶇嚎绋嬭皟鐢� send_and_wait锛岄樆濉炵洿鍒颁换鍔″畬鎴�
 //                bool result = client->send_binary_and_wait(binary_data, timeout_ms);
-//                client->set_busy(false); // 设置为空闲状态
-//                return result; // 返回结果
+//                client->set_busy(false); // 璁剧疆涓虹┖闂茬姸鎬�
+//                return result; // 杩斿洖缁撴灉
 //            }
 //            catch (const std::exception& e) {
 //                std::cerr << "Exception during sending: " << e.what() << std::endl;
-//                client->set_busy(false); // 即使发生异常,也要重置为未忙状态
-//                return false; // 发生异常,返回失败
+//                client->set_busy(false); // 鍗充娇鍙戠敓寮傚父锛屼篃瑕侀噸缃负鏈繖鐘舵��
+//                return false; // 鍙戠敓寮傚父锛岃繑鍥炲け璐�
 //            }
 //        }
 //    }
-//    return false; // 没有空闲客户端
+//    return false; // 娌℃湁绌洪棽瀹㈡埛绔�
 //}
 //
 //bool WebSocketClientPool::send_to_idle_client_with_retry(const std::string& message, int total_timeout_ms, int retry_interval_ms) {
 //	auto start_time = std::chrono::steady_clock::now();
 //
 //	while (true) {
-//		// 查找空闲客户端
+//		// 鏌ユ壘绌洪棽瀹㈡埛绔�
 //		for (auto& client : m_clients) {
 //			if (!client->is_busy() && client->is_connected()) {
-//				// 标记为忙
+//				// 鏍囪涓哄繖
 //				client->set_busy(true);
 //
-//				// 使用线程池发送消息
+//				// 浣跨敤绾跨▼姹犲彂閫佹秷鎭�
 //				m_thread_pool.enqueue([client, message]() {
 //					try {
-//						// 发送消息并等待服务器回复
-//						client->send_and_wait(message, 5000); // 这里的超时可以根据需要调整
+//						// 鍙戦�佹秷鎭苟绛夊緟鏈嶅姟鍣ㄥ洖澶�
+//						client->send_and_wait(message, 5000); // 杩欓噷鐨勮秴鏃跺彲浠ユ牴鎹渶瑕佽皟鏁�
 //					}
 //					catch (const std::exception& e) {
 //						std::cerr << "Error sending data: " << e.what() << std::endl;
 //					}
-//					client->set_busy(false); // 标记为空闲
+//					client->set_busy(false); // 鏍囪涓虹┖闂�
 //			    });
 //
-//				return true; // 成功发送
+//				return true; // 鎴愬姛鍙戦��
 //			}
 //		}
 //
-//		// 计算已使用的时间
+//		// 璁$畻宸蹭娇鐢ㄧ殑鏃堕棿
 //		auto elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start_time).count();
 //
 //		if (elapsed_time >= total_timeout_ms) {
 //			std::cerr << "Timeout: failed to send data within the specified timeout of " << total_timeout_ms << " ms." << std::endl;
-//			return false; // 超时,无法发送
+//			return false; // 瓒呮椂锛屾棤娉曞彂閫�
 //		}
 //
-//		// 没有找到空闲客户端,等待 retry_interval_ms 毫秒后重试
+//		// 娌℃湁鎵惧埌绌洪棽瀹㈡埛绔紝绛夊緟 retry_interval_ms 姣鍚庨噸璇�
 //		std::this_thread::sleep_for(std::chrono::milliseconds(retry_interval_ms));
 //	}
 //}
@@ -212,37 +212,37 @@
 //    auto start_time = std::chrono::steady_clock::now();
 //
 //    while (true) {
-//        // 查找空闲客户端
+//        // 鏌ユ壘绌洪棽瀹㈡埛绔�
 //        for (auto& client : m_clients) {
 //            if (!client->is_busy() && client->is_connected()) {
-//                // 标记为忙
+//                // 鏍囪涓哄繖
 //                client->set_busy(true);
 //
-//                // 使用线程池发送消息
+//                // 浣跨敤绾跨▼姹犲彂閫佹秷鎭�
 //                m_thread_pool.enqueue([client, binary_data = std::move(binary_data)]() mutable {
 //                    try {
-//                        // 发送消息并等待服务器回复
-//                        client->send_binary_and_wait(binary_data, 5000); // 这里的超时可以根据需要调整
+//                        // 鍙戦�佹秷鎭苟绛夊緟鏈嶅姟鍣ㄥ洖澶�
+//                        client->send_binary_and_wait(binary_data, 5000); // 杩欓噷鐨勮秴鏃跺彲浠ユ牴鎹渶瑕佽皟鏁�
 //                    }
 //                    catch (const std::exception& e) {
 //                        std::cerr << "Error sending binary data: " << e.what() << std::endl;
 //                    }
-//                    client->set_busy(false); // 标记为空闲
+//                    client->set_busy(false); // 鏍囪涓虹┖闂�
 //                });
 //
-//                return true; // 成功发送
+//                return true; // 鎴愬姛鍙戦��
 //            }
 //        }
 //
-//        // 计算已使用的时间
+//        // 璁$畻宸蹭娇鐢ㄧ殑鏃堕棿
 //        auto elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start_time).count();
 //
 //        if (elapsed_time >= total_timeout_ms) {
 //            std::cerr << "Timeout: failed to send data within the specified timeout of " << total_timeout_ms << " ms." << std::endl;
-//            return false; // 超时,无法发送
+//            return false; // 瓒呮椂锛屾棤娉曞彂閫�
 //        }
 //
-//        // 没有找到空闲客户端,等待 retry_interval_ms 毫秒后重试
+//        // 娌℃湁鎵惧埌绌洪棽瀹㈡埛绔紝绛夊緟 retry_interval_ms 姣鍚庨噸璇�
 //        std::this_thread::sleep_for(std::chrono::milliseconds(retry_interval_ms));
 //    }
 //}

--
Gitblit v1.9.3