From 14db1514fec89db599766d4996b4bb1fead0eff0 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 25 八月 2022 17:49:54 +0800
Subject: [PATCH] '完善'

---
 app/SocketManager.cpp |   30 +++++++++---------------------
 1 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/app/SocketManager.cpp b/app/SocketManager.cpp
index dc80b01..827c33d 100644
--- a/app/SocketManager.cpp
+++ b/app/SocketManager.cpp
@@ -4,6 +4,7 @@
 #include <thread>
 #include <string>
 
+
 SOCKET SocketManager::socketServer;
 
 ActionCallback SocketManager::actionCallback;
@@ -14,7 +15,7 @@
 
 SocketManager::SocketManager(ActionCallback callback, void* context) {
 
-	init(callback,context);
+	init(callback, context);
 }
 
 SocketManager::~SocketManager() {
@@ -31,26 +32,13 @@
 		if (recv_len > 0)
 		{
 			cout << "接受到操作指令:" << recvBuff << endl;
-			try {
-				bool success = actionCallback(string(recvBuff), callbackContext);
-				//发送操作结果
-				if (success)
-				{
-					char buff[] = "OK";
-					int iSend = send(client, buff, sizeof(buff), 0);
-					cout << "返回给客户端数据:" << buff << endl;
-				}
-				else {
-					char buff[] = "FAIL";
-					int iSend = send(client, buff, sizeof(buff), 0);
-					cout << "返回给客户端数据:" << buff << endl;
-				}
-			}
-			catch (string st) {
-				char buff[] = "FAIL";
-				int iSend = send(client, buff, sizeof(buff), 0);
-				cout << "设置采集代码出错:" << st << endl;
-			}
+
+
+			string result = actionCallback(string(recvBuff), callbackContext);
+
+			//发送操作结果
+			int iSend = send(client, result.c_str(), result.size(), 0);
+			cout << "返回给客户端数据:" << result << endl;
 		}
 		else {
 			cout << "客户端退出" << endl;

--
Gitblit v1.8.0