@@ -22,6 +22,55 @@ CModuleProtocol_Packet::~CModuleProtocol_Packet()
2222// 公有函数
2323// ////////////////////////////////////////////////////////////////////////
2424/* *******************************************************************
25+ 函数名称:ModuleProtocol_Packet_Common
26+ 函数功能:公用协议打包函数
27+ 参数.一:ptszMsgBuffer
28+ In/Out:Out
29+ 类型:字符指针
30+ 可空:N
31+ 意思:输出打好包的缓冲区
32+ 参数.二:pInt_MsgLen
33+ In/Out:Out
34+ 类型:整数型指针
35+ 可空:N
36+ 意思:输出缓冲区大小
37+ 参数.三:nCode
38+ In/Out:In
39+ 类型:整数型
40+ 可空:Y
41+ 意思:输入返回的值
42+ 参数.四:lpszMsgBuffer
43+ In/Out:In
44+ 类型:常量字符指针
45+ 可空:Y
46+ 意思:输入要打包的后续内容
47+ 返回值
48+ 类型:逻辑型
49+ 意思:是否成功
50+ 备注:
51+ *********************************************************************/
52+ BOOL CModuleProtocol_Packet::ModuleProtocol_Packet_Common (TCHAR* ptszMsgBuffer, int * pInt_MsgLen, int nCode /* = 0 */ , LPCTSTR lpszMsgBuffer /* = NULL */ )
53+ {
54+ ModuleProtocol_IsErrorOccur = FALSE ;
55+
56+ if ((NULL == ptszMsgBuffer) || (NULL == pInt_MsgLen))
57+ {
58+ ModuleProtocol_IsErrorOccur = TRUE ;
59+ ModuleProtocol_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PROTOCOL_PACKET_PARAMENT;
60+ return FALSE ;
61+ }
62+ Json::Value st_JsonRoot;
63+
64+ st_JsonRoot[" code" ] = 0 ;
65+ if (NULL != lpszMsgBuffer)
66+ {
67+ st_JsonRoot[" msg" ] = lpszMsgBuffer;
68+ }
69+ *pInt_MsgLen = st_JsonRoot.toStyledString ().length ();
70+ memcpy (ptszMsgBuffer, st_JsonRoot.toStyledString ().c_str (), *pInt_MsgLen);
71+ return TRUE ;
72+ }
73+ /* *******************************************************************
2574函数名称:ModuleProtocol_Packet_IPQuery
2675函数功能:IP地址查询打包协议
2776 参数.一:ptszMsgBuffer
@@ -636,55 +685,6 @@ BOOL CModuleProtocol_Packet::ModuleProtocol_Packet_LanguageQuery2(TCHAR* ptszMsg
636685 return TRUE ;
637686}
638687/* *******************************************************************
639- 函数名称:ModuleProtocol_Packet_P2PCommon
640- 函数功能:P2XP公用协议打包函数
641- 参数.一:ptszMsgBuffer
642- In/Out:Out
643- 类型:字符指针
644- 可空:N
645- 意思:输出打好包的缓冲区
646- 参数.二:pInt_MsgLen
647- In/Out:Out
648- 类型:整数型指针
649- 可空:N
650- 意思:输出缓冲区大小
651- 参数.三:nCode
652- In/Out:In
653- 类型:整数型
654- 可空:Y
655- 意思:输入返回的值
656- 参数.四:lpszMsgBuffer
657- In/Out:In
658- 类型:常量字符指针
659- 可空:Y
660- 意思:输入要打包的后续内容
661- 返回值
662- 类型:逻辑型
663- 意思:是否成功
664- 备注:
665- *********************************************************************/
666- BOOL CModuleProtocol_Packet::ModuleProtocol_Packet_P2PCommon (TCHAR* ptszMsgBuffer, int * pInt_MsgLen, int nCode /* = 0 */ , LPCTSTR lpszMsgBuffer /* = NULL */ )
667- {
668- ModuleProtocol_IsErrorOccur = FALSE ;
669-
670- if ((NULL == ptszMsgBuffer) || (NULL == pInt_MsgLen))
671- {
672- ModuleProtocol_IsErrorOccur = TRUE ;
673- ModuleProtocol_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PROTOCOL_PACKET_PARAMENT;
674- return FALSE ;
675- }
676- Json::Value st_JsonRoot;
677-
678- st_JsonRoot[" nCode" ] = 0 ;
679- if (NULL != lpszMsgBuffer)
680- {
681- st_JsonRoot[" lpszMsgBuffer" ] = lpszMsgBuffer;
682- }
683- *pInt_MsgLen = st_JsonRoot.toStyledString ().length ();
684- memcpy (ptszMsgBuffer, st_JsonRoot.toStyledString ().c_str (), *pInt_MsgLen);
685- return TRUE ;
686- }
687- /* *******************************************************************
688688函数名称:ModuleProtocol_Packet_P2PLan
689689函数功能:响应同步局域网地址列表
690690 参数.一:ptszMsgBuffer
@@ -731,8 +731,8 @@ BOOL CModuleProtocol_Packet::ModuleProtocol_Packet_P2PLan(TCHAR* ptszMsgBuffer,
731731 st_JsonObject[" ClientAddr" ] = (*pppSt_ListClients)[i]->tszPrivateAddr ;
732732 st_JsonArray.append (st_JsonObject);
733733 }
734- st_JsonRoot[" nCode " ] = 0 ;
735- st_JsonRoot[" lpszMsgBuffer " ] = " sucess" ;
734+ st_JsonRoot[" code " ] = 0 ;
735+ st_JsonRoot[" msg " ] = " sucess" ;
736736 st_JsonRoot[" ClientArray" ] = st_JsonArray;
737737 st_JsonRoot[" ClientCount" ] = nListCount;
738738
@@ -824,8 +824,8 @@ BOOL CModuleProtocol_Packet::ModuleProtocol_Packet_P2PWLan(TCHAR* ptszMsgBuffer,
824824 st_JsonArray[" tszLANAddr" ] = stl_MapIterator->first .c_str ();
825825 st_JsonArray[" tszLANList" ] = st_JsonList;
826826 }
827- st_JsonRoot[" nCode " ] = 0 ;
828- st_JsonRoot[" lpszMsgBuffer " ] = " sucess" ;
827+ st_JsonRoot[" code " ] = 0 ;
828+ st_JsonRoot[" msg " ] = " sucess" ;
829829 st_JsonRoot[" ClientArray" ] = st_JsonArray;
830830 st_JsonRoot[" ClientCount" ] = nCount;
831831
@@ -876,7 +876,7 @@ BOOL CModuleProtocol_Packet::ModuleProtocol_Packet_P2PUser(TCHAR* ptszMsgBuffer,
876876 Json::StreamWriterBuilder st_JsonBuilder;
877877
878878 st_JsonRoot[" Code" ] = 0 ;
879- st_JsonRoot[" lpszMsgBuffer " ] = " sucess" ;
879+ st_JsonRoot[" msg " ] = " sucess" ;
880880 st_JsonRoot[" dwConnectType" ] = (Json::Value::UInt)pSt_PeerInfo->dwConnectType ;
881881 st_JsonRoot[" dwPeerType" ] = pSt_PeerInfo->dwPeerType ;
882882 st_JsonRoot[" tszConnectAddr" ] = pSt_PeerInfo->tszConnectAddr ;
0 commit comments