Browse Source

初步完成通信;

Jeff 5 years ago
parent
commit
faf2b01f59

+ 10 - 1
VideoCapture/VideoCapture/IOCPModel.cpp

@@ -884,13 +884,22 @@ void CIOCPModel::_DeviceProc(PER_SOCKET_CONTEXT* pSocketContext, Package* pak)
 		return;
 	}
 
+	// Ïò´®¿Ú·¢ËÍÖ¸Áî;
 	auto value = iter->second;
 	std::string readdata = value.SendCommond(reqj.device_cmd);
 
 	ResponseJson repj;
 	repj.device_id = reqj.device_id;
 	repj.device_name = reqj.device_name;
-	repj.device_result_des = readdata;
+	repj.device_cmd_result = readdata;
+
+	pJson = cJSON_CreateObject();
+	cJSON_AddNumberToObject(pJson, "device_id", repj.device_id);
+	cJSON_AddStringToObject(pJson, "device_name", repj.device_name.c_str());
+	cJSON_AddNumberToObject(pJson, "device_cmd_result", repj.device_cmd_result.c_str());
+
+	char* pjdata = cJSON_Print(pJson);
+	send(pSocketContext->m_Socket, pjdata, strlen(pjdata), 0);
 }
 
 /////////////////////////////////////////////////////////////////////

+ 1 - 2
VideoCapture/VideoCapture/IOCPModel.h

@@ -39,8 +39,7 @@ typedef struct _RESPONSE_JSON_
 {
 	int			device_id;
 	std::string		device_name;
-	bool		device_cmd_result;	// 命令执行结果;
-	std::string device_result_des;	// 结果描述;
+	std::string device_cmd_result;	// 命令执行结果;
 }ResponseJson;
 
 

+ 1 - 1
VideoCapture/VideoCapture/VideoCapture.vcxproj

@@ -97,7 +97,7 @@ copy "$(SolutionDir)AMESDK.DLL" "$(TargetDir)AMESDK.dll" /y/a</Command>
       <Optimization>MaxSpeed</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <SDLCheck>true</SDLCheck>
+      <SDLCheck>false</SDLCheck>
       <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeaderFile>StdAfx.h</PrecompiledHeaderFile>
       <AdditionalIncludeDirectories>..\UI;..\filehelper;..\cJson</AdditionalIncludeDirectories>