Skip to content

Commit b5e5435

Browse files
committed
added:zipcode protocol packet and parse
1 parent f3f2609 commit b5e5435

File tree

7 files changed

+212
-2
lines changed

7 files changed

+212
-2
lines changed

XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Define.h

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,40 @@ extern "C" BOOL ModuleProtocol_Packet_LanguageQuery(TCHAR* ptszMsgBuffer, int* p
256256
*********************************************************************/
257257
extern "C" BOOL ModuleProtocol_Packet_Locker(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, XNETHANDLE xhToken, int nCode = 0, LPCTSTR lpszMsgBuffer = NULL);
258258
/********************************************************************
259+
函数名称:ModuleProtocol_Packet_ZIPCode
260+
函数功能:打包行政邮编信息协议
261+
参数.一:ptszMsgBuffer
262+
In/Out:Out
263+
类型:字符指针
264+
可空:N
265+
意思:输出打包的数据信息
266+
参数.二:pInt_MsgLen
267+
In/Out:Out
268+
类型:整数型指针
269+
可空:N
270+
意思:输出打包大小
271+
参数.三:pSt_ZIPInfo
272+
In/Out:In
273+
类型:数据结构指针
274+
可空:N
275+
意思:输入要打包的数据
276+
参数.四:nCode
277+
In/Out:In
278+
类型:整数型
279+
可空:Y
280+
意思:输入返回的值
281+
参数.五:lpszMsgBuffer
282+
In/Out:In
283+
类型:常量字符指针
284+
可空:Y
285+
意思:输入操作结果
286+
返回值
287+
类型:逻辑型
288+
意思:是否成功
289+
备注:
290+
*********************************************************************/
291+
extern "C" BOOL ModuleProtocol_Packet_ZIPCode(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_ZIPINFO* pSt_ZIPInfo, int nCode = 0, LPCTSTR lpszMsgBuffer = NULL);
292+
/********************************************************************
259293
函数名称:ModuleProtocol_Packet_P2PLan
260294
函数功能:响应同步局域网地址列表
261295
参数.一:ptszMsgBuffer
@@ -483,4 +517,28 @@ extern "C" BOOL ModuleProtocol_Parse_P2PClient(LPCTSTR lpszMsgBuffer, int nMsgLe
483517
意思:是否成功
484518
备注:
485519
*********************************************************************/
486-
extern "C" BOOL ModuleProtocol_Parse_CDKey(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_AUTHORIZE_LOCAL* pSt_Authorize);
520+
extern "C" BOOL ModuleProtocol_Parse_CDKey(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_AUTHORIZE_LOCAL* pSt_Authorize);
521+
/********************************************************************
522+
函数名称:ModuleProtocol_Parse_ZIPCode
523+
函数功能:解析邮政地址信息
524+
参数.一:lpszMsgBuffer
525+
In/Out:In
526+
类型:常量字符指针
527+
可空:N
528+
意思:输入要解析的缓冲区
529+
参数.二:nMsgLen
530+
In/Out:In
531+
类型:整数型
532+
可空:N
533+
意思:输入缓冲区大小
534+
参数.三:pSt_ZIPInfo
535+
In/Out:Out
536+
类型:数据结构指针
537+
可空:N
538+
意思:输出解析后的信息
539+
返回值
540+
类型:逻辑型
541+
意思:是否成功
542+
备注:
543+
*********************************************************************/
544+
extern "C" BOOL ModuleProtocol_Parse_ZIPCode(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_ZIPINFO* pSt_ZIPInfo);

XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.cpp

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,82 @@ BOOL CModuleProtocol_Packet::ModuleProtocol_Packet_Locker(TCHAR* ptszMsgBuffer,
509509
return TRUE;
510510
}
511511
/********************************************************************
512+
函数名称:ModuleProtocol_Packet_ZIPCode
513+
函数功能:打包行政邮编信息协议
514+
参数.一:ptszMsgBuffer
515+
In/Out:Out
516+
类型:字符指针
517+
可空:N
518+
意思:输出打包的数据信息
519+
参数.二:pInt_MsgLen
520+
In/Out:Out
521+
类型:整数型指针
522+
可空:N
523+
意思:输出打包大小
524+
参数.三:pSt_ZIPInfo
525+
In/Out:In
526+
类型:数据结构指针
527+
可空:N
528+
意思:输入要打包的数据
529+
参数.四:nCode
530+
In/Out:In
531+
类型:整数型
532+
可空:Y
533+
意思:输入返回的值
534+
参数.五:lpszMsgBuffer
535+
In/Out:In
536+
类型:常量字符指针
537+
可空:Y
538+
意思:输入操作结果
539+
返回值
540+
类型:逻辑型
541+
意思:是否成功
542+
备注:
543+
*********************************************************************/
544+
BOOL CModuleProtocol_Packet::ModuleProtocol_Packet_ZIPCode(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_ZIPINFO* pSt_ZIPInfo, int nCode /* = 0 */, LPCTSTR lpszMsgBuffer /* = NULL */)
545+
{
546+
ModuleProtocol_IsErrorOccur = FALSE;
547+
548+
if ((NULL == ptszMsgBuffer) || (NULL == pInt_MsgLen))
549+
{
550+
ModuleProtocol_IsErrorOccur = TRUE;
551+
ModuleProtocol_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PROTOCOL_PACKET_PARAMENT;
552+
return FALSE;
553+
}
554+
Json::Value st_JsonRoot;
555+
Json::Value st_JsonObject;
556+
Json::StreamWriterBuilder st_JsonBuilder;
557+
558+
if (0 == nCode)
559+
{
560+
st_JsonObject["dlLat"] = pSt_ZIPInfo->dlLat;
561+
st_JsonObject["dlLng"] = pSt_ZIPInfo->dlLng;
562+
st_JsonObject["nAreaCode"] = pSt_ZIPInfo->nAreaCode;
563+
st_JsonObject["nLevel"] = pSt_ZIPInfo->nLevel;
564+
st_JsonObject["nZipCode"] = pSt_ZIPInfo->nZipCode;
565+
st_JsonObject["tszCity"] = pSt_ZIPInfo->tszCity;
566+
st_JsonObject["tszCounty"] = pSt_ZIPInfo->tszCounty;
567+
st_JsonObject["tszPinYin"] = pSt_ZIPInfo->tszPinYin;
568+
st_JsonObject["tszProvincer"] = pSt_ZIPInfo->tszProvincer;
569+
}
570+
571+
st_JsonRoot["code"] = nCode;
572+
if (NULL == lpszMsgBuffer)
573+
{
574+
st_JsonRoot["msg"] = "success";
575+
}
576+
else
577+
{
578+
st_JsonRoot["msg"] = lpszMsgBuffer;
579+
}
580+
st_JsonRoot["data"] = st_JsonObject;
581+
st_JsonBuilder["emitUTF8"] = true;
582+
583+
*pInt_MsgLen = Json::writeString(st_JsonBuilder, st_JsonRoot).length();
584+
memcpy(ptszMsgBuffer, Json::writeString(st_JsonBuilder, st_JsonRoot).c_str(), *pInt_MsgLen);
585+
return TRUE;
586+
}
587+
/********************************************************************
512588
函数名称:ModuleProtocol_Packet_P2PLan
513589
函数功能:响应同步局域网地址列表
514590
参数.一:ptszMsgBuffer

XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class CModuleProtocol_Packet
2929
BOOL ModuleProtocol_Packet_BankQuery(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_BANKINFO* pSt_BankInfo, int nCode = 0, LPCTSTR lpszMsgBuffer = NULL);
3030
BOOL ModuleProtocol_Packet_LanguageQuery(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_LANGUAGEINFO* pSt_LanguageInfo, int nCode = 0, LPCTSTR lpszMsgBuffer = NULL);
3131
BOOL ModuleProtocol_Packet_Locker(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, XNETHANDLE xhToken, int nCode = 0, LPCTSTR lpszMsgBuffer = NULL);
32+
BOOL ModuleProtocol_Packet_ZIPCode(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_ZIPINFO* pSt_ZIPInfo, int nCode = 0, LPCTSTR lpszMsgBuffer = NULL);
3233
public:
3334
BOOL ModuleProtocol_Packet_P2PLan(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_P2XPPEER_PROTOCOL*** pppSt_ListClients, int nListCount);
3435
BOOL ModuleProtocol_Packet_P2PWLan(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, list<XENGINE_P2XPPEER_PROTOCOL>* pStl_ListClients);

XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Parse/ModuleProtocol_Parse.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,4 +443,68 @@ BOOL CModuleProtocol_Parse::ModuleProtocol_Parse_CDKey(LPCTSTR lpszMsgBuffer, in
443443
_tcscpy(pSt_Authorize->st_AuthUserInfo.tszCustom, st_JsonUserInfo["tszCustom"].asCString());
444444
}
445445
return TRUE;
446+
}
447+
/********************************************************************
448+
函数名称:ModuleProtocol_Parse_ZIPCode
449+
函数功能:解析邮政地址信息
450+
参数.一:lpszMsgBuffer
451+
In/Out:In
452+
类型:常量字符指针
453+
可空:N
454+
意思:输入要解析的缓冲区
455+
参数.二:nMsgLen
456+
In/Out:In
457+
类型:整数型
458+
可空:N
459+
意思:输入缓冲区大小
460+
参数.三:pSt_ZIPInfo
461+
In/Out:Out
462+
类型:数据结构指针
463+
可空:N
464+
意思:输出解析后的信息
465+
返回值
466+
类型:逻辑型
467+
意思:是否成功
468+
备注:
469+
*********************************************************************/
470+
BOOL CModuleProtocol_Parse::ModuleProtocol_Parse_ZIPCode(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_ZIPINFO* pSt_ZIPInfo)
471+
{
472+
ModuleProtocol_IsErrorOccur = FALSE;
473+
474+
if ((NULL == lpszMsgBuffer) || (NULL == pSt_ZIPInfo))
475+
{
476+
ModuleProtocol_IsErrorOccur = TRUE;
477+
ModuleProtocol_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PROTOCOL_PARSE_PARAMENT;
478+
return FALSE;
479+
}
480+
Json::Value st_JsonRoot;
481+
JSONCPP_STRING st_JsonError;
482+
Json::CharReaderBuilder st_ReaderBuilder;
483+
//解析JSON
484+
std::unique_ptr<Json::CharReader> const pSt_JsonReader(st_ReaderBuilder.newCharReader());
485+
if (!pSt_JsonReader->parse(lpszMsgBuffer, lpszMsgBuffer + nMsgLen, &st_JsonRoot, &st_JsonError))
486+
{
487+
ModuleProtocol_IsErrorOccur = TRUE;
488+
ModuleProtocol_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PROTOCOL_PARSE_PARAMENT;
489+
return FALSE;
490+
}
491+
492+
if (!st_JsonRoot["tszProvincer"].isNull())
493+
{
494+
_tcscpy(pSt_ZIPInfo->tszProvincer, st_JsonRoot["tszProvincer"].asCString());
495+
}
496+
if (!st_JsonRoot["tszCity"].isNull())
497+
{
498+
_tcscpy(pSt_ZIPInfo->tszCity, st_JsonRoot["tszCity"].asCString());
499+
}
500+
if (!st_JsonRoot["tszCounty"].isNull())
501+
{
502+
_tcscpy(pSt_ZIPInfo->tszCounty, st_JsonRoot["tszCounty"].asCString());
503+
}
504+
505+
if (!st_JsonRoot["nZipCode"].isNull())
506+
{
507+
pSt_ZIPInfo->nZipCode = st_JsonRoot["nZipCode"].asInt();
508+
}
509+
return TRUE;
446510
}

XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Parse/ModuleProtocol_Parse.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ class CModuleProtocol_Parse
2323
BOOL ModuleProtocol_Parse_Translation(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_LANGUAGEINFO* pSt_LanguageInfo);
2424
BOOL ModuleProtocol_Parse_P2PClient(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_P2XPPEER_PROTOCOL* pSt_P2XPPeer);
2525
BOOL ModuleProtocol_Parse_CDKey(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_AUTHORIZE_LOCAL* pSt_Authorize);
26+
BOOL ModuleProtocol_Parse_ZIPCode(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_ZIPINFO* pSt_ZIPInfo);
2627
private:
2728
};

XEngine_Source/XEngine_ModuleProtocol/XEngine_ModuleProtocol.def

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ EXPORTS
1010
ModuleProtocol_Packet_BankQuery
1111
ModuleProtocol_Packet_LanguageQuery
1212
ModuleProtocol_Packet_Locker
13+
ModuleProtocol_Packet_ZIPCode
1314
ModuleProtocol_Packet_P2PLan
1415
ModuleProtocol_Packet_P2PWLan
1516
ModuleProtocol_Packet_P2PUser
@@ -19,4 +20,5 @@ EXPORTS
1920
ModuleProtocol_Parse_Bank
2021
ModuleProtocol_Parse_Translation
2122
ModuleProtocol_Parse_P2PClient
22-
ModuleProtocol_Parse_CDKey
23+
ModuleProtocol_Parse_CDKey
24+
ModuleProtocol_Parse_ZIPCode

XEngine_Source/XEngine_ModuleProtocol/pch.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ extern "C" BOOL ModuleProtocol_Packet_Locker(TCHAR * ptszMsgBuffer, int* pInt_Ms
5959
{
6060
return m_ProtocolPacket.ModuleProtocol_Packet_Locker(ptszMsgBuffer, pInt_MsgLen, xhToken, nCode, lpszMsgBuffer);
6161
}
62+
extern "C" BOOL ModuleProtocol_Packet_ZIPCode(TCHAR * ptszMsgBuffer, int* pInt_MsgLen, XENGINE_ZIPINFO * pSt_ZIPInfo, int nCode, LPCTSTR lpszMsgBuffer)
63+
{
64+
return m_ProtocolPacket.ModuleProtocol_Packet_ZIPCode(ptszMsgBuffer, pInt_MsgLen, pSt_ZIPInfo, nCode, lpszMsgBuffer);
65+
}
6266
extern "C" BOOL ModuleProtocol_Packet_P2PLan(TCHAR * ptszMsgBuffer, int* pInt_MsgLen, XENGINE_P2XPPEER_PROTOCOL * **pppSt_ListClients, int nListCount)
6367
{
6468
return m_ProtocolPacket.ModuleProtocol_Packet_P2PLan(ptszMsgBuffer, pInt_MsgLen, pppSt_ListClients, nListCount);
@@ -97,4 +101,8 @@ extern "C" BOOL ModuleProtocol_Parse_P2PClient(LPCTSTR lpszMsgBuffer, int nMsgLe
97101
extern "C" BOOL ModuleProtocol_Parse_CDKey(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_AUTHORIZE_LOCAL * pSt_Authorize)
98102
{
99103
return m_ProtocolParse.ModuleProtocol_Parse_CDKey(lpszMsgBuffer, nMsgLen, pSt_Authorize);
104+
}
105+
extern "C" BOOL ModuleProtocol_Parse_ZIPCode(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_ZIPINFO * pSt_ZIPInfo)
106+
{
107+
return m_ProtocolParse.ModuleProtocol_Parse_ZIPCode(lpszMsgBuffer, nMsgLen, pSt_ZIPInfo);
100108
}

0 commit comments

Comments
 (0)