提交 6684a803 编写于 作者: xengine-qyt's avatar xengine-qyt

added:short link protocol parse and packet support

上级 9697081a
......@@ -433,6 +433,30 @@ extern "C" XBOOL ModuleProtocol_Packet_P2PConnect(XCHAR* ptszMsgBuffer, int* pIn
备注:
*********************************************************************/
extern "C" XBOOL ModuleProtocol_Packet_Log(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_XLOGINFO*** pppSt_XLogList, int nListCount);
/********************************************************************
函数名称:ModuleProtocol_Packet_ShortLink
函数功能:短连接生成协议打包函数
参数.一:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:输出打包的数据信息
参数.二:pInt_MsgLen
In/Out:Out
类型:整数型指针
可空:N
意思:输出打包大小
参数.三:pSt_ShortLink
In/Out:In
类型:数据结构
可空:N
意思:输入要打包的信息
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" XBOOL ModuleProtocol_Packet_ShortLink(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_SHORTLINK* pSt_ShortLink);
/************************************************************************/
/* 导出的协议解析函数 */
/************************************************************************/
......@@ -622,4 +646,28 @@ extern "C" XBOOL ModuleProtocol_Parse_QRCode(LPCXSTR lpszMsgBuffer, int nMsgLen,
意思:是否成功
备注:
*********************************************************************/
extern "C" XBOOL ModuleProtocol_Parse_SocketTest(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_SOCKETTEST* pSt_SocketTest);
\ No newline at end of file
extern "C" XBOOL ModuleProtocol_Parse_SocketTest(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_SOCKETTEST* pSt_SocketTest);
/********************************************************************
函数名称:ModuleProtocol_Parse_ShortLink
函数功能:短连接协议解析
参数.一:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:N
意思:输入要解析的数据
参数.二:nMsgLen
In/Out:In
类型:整数型
可空:N
意思:pSt_SocketTest
参数.三:pSt_ShortLink
In/Out:Out
类型:数据结构指针
可空:N
意思:输出解析好的信息
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" XBOOL ModuleProtocol_Parse_ShortLink(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_SHORTLINK* pSt_ShortLink);
\ No newline at end of file
......@@ -662,6 +662,59 @@ XBOOL CModuleProtocol_Packet::ModuleProtocol_Packet_TestReply(XCHAR* ptszMsgBuff
return XTRUE;
}
/********************************************************************
函数名称:ModuleProtocol_Packet_ShortLink
函数功能:短连接生成协议打包函数
参数.一:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:输出打包的数据信息
参数.二:pInt_MsgLen
In/Out:Out
类型:整数型指针
可空:N
意思:输出打包大小
参数.三:pSt_ShortLink
In/Out:In
类型:数据结构
可空:N
意思:输入要打包的信息
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
XBOOL CModuleProtocol_Packet::ModuleProtocol_Packet_ShortLink(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_SHORTLINK* pSt_ShortLink)
{
ModuleProtocol_IsErrorOccur = XFALSE;
if ((NULL == ptszMsgBuffer) || (NULL == pInt_MsgLen))
{
ModuleProtocol_IsErrorOccur = XTRUE;
ModuleProtocol_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PROTOCOL_PACKET_PARAMENT;
return XFALSE;
}
Json::Value st_JsonRoot;
Json::Value st_JsonObject;
Json::StreamWriterBuilder st_JsonBuilder;
st_JsonObject["tszFullUrl"] = pSt_ShortLink->tszFullUrl;
st_JsonObject["tszShotUrl"] = pSt_ShortLink->tszShotUrl;
st_JsonObject["tszKeyUrl"] = pSt_ShortLink->tszKeyUrl;
st_JsonObject["tszMapUrl"] = pSt_ShortLink->tszMapUrl;
st_JsonObject["tszCvtUrl"] = pSt_ShortLink->tszCvtUrl;
st_JsonObject["tszCreateTime"] = pSt_ShortLink->tszCreateTime;
st_JsonRoot["code"] = 0;
st_JsonRoot["msg"] = "success";
st_JsonRoot["data"] = st_JsonObject;
st_JsonBuilder["emitUTF8"] = true;
*pInt_MsgLen = Json::writeString(st_JsonBuilder, st_JsonRoot).length();
memcpy(ptszMsgBuffer, Json::writeString(st_JsonBuilder, st_JsonRoot).c_str(), *pInt_MsgLen);
return XTRUE;
}
/********************************************************************
函数名称:ModuleProtocol_Packet_P2PLan
函数功能:响应同步局域网地址列表
参数.一:ptszMsgBuffer
......
......@@ -31,6 +31,7 @@ public:
XBOOL ModuleProtocol_Packet_Log(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_XLOGINFO*** pppSt_XLogList, int nListCount);
XBOOL ModuleProtocol_Packet_TestReport(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XNETHANDLE xhToken, LPCXSTR lpszIPAddr, int nIPPort, __int64x nNumber, __int64x nFailed, __int64x nSuccess, int nStatus);
XBOOL ModuleProtocol_Packet_TestReply(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XNETHANDLE xhToken);
XBOOL ModuleProtocol_Packet_ShortLink(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_SHORTLINK* pSt_ShortLink);
public:
XBOOL ModuleProtocol_Packet_P2PLan(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_P2XPPEER_PROTOCOL*** pppSt_ListClients, int nListCount);
XBOOL ModuleProtocol_Packet_P2PWLan(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, list<XENGINE_P2XPPEER_PROTOCOL>* pStl_ListClients);
......
......@@ -621,4 +621,79 @@ XBOOL CModuleProtocol_Parse::ModuleProtocol_Parse_SocketTest(LPCXSTR lpszMsgBuff
pSt_SocketTest->st_SocketData.nSDLen = st_JsonRoot["nSDLen"].asInt();
}
return XTRUE;
}
/********************************************************************
函数名称:ModuleProtocol_Parse_ShortLink
函数功能:短连接协议解析
参数.一:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:N
意思:输入要解析的数据
参数.二:nMsgLen
In/Out:In
类型:整数型
可空:N
意思:pSt_SocketTest
参数.三:pSt_ShortLink
In/Out:Out
类型:数据结构指针
可空:N
意思:输出解析好的信息
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
XBOOL CModuleProtocol_Parse::ModuleProtocol_Parse_ShortLink(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_SHORTLINK* pSt_ShortLink)
{
ModuleProtocol_IsErrorOccur = XFALSE;
if ((NULL == lpszMsgBuffer) || (NULL == pSt_ShortLink))
{
ModuleProtocol_IsErrorOccur = XTRUE;
ModuleProtocol_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PROTOCOL_PARSE_PARAMENT;
return XFALSE;
}
Json::Value st_JsonRoot;
JSONCPP_STRING st_JsonError;
Json::CharReaderBuilder st_ReaderBuilder;
//解析JSON
std::unique_ptr<Json::CharReader> const pSt_JsonReader(st_ReaderBuilder.newCharReader());
if (!pSt_JsonReader->parse(lpszMsgBuffer, lpszMsgBuffer + nMsgLen, &st_JsonRoot, &st_JsonError))
{
ModuleProtocol_IsErrorOccur = XTRUE;
ModuleProtocol_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PROTOCOL_PARSE_PARAMENT;
return XFALSE;
}
if (!st_JsonRoot["tszFullUrl"].isNull())
{
_tcscpy(pSt_ShortLink->tszFullUrl, st_JsonRoot["tszFullUrl"].asCString());
}
if (!st_JsonRoot["tszShotUrl"].isNull())
{
_tcscpy(pSt_ShortLink->tszShotUrl, st_JsonRoot["tszShotUrl"].asCString());
}
if (!st_JsonRoot["tszKeyUrl"].isNull())
{
_tcscpy(pSt_ShortLink->tszKeyUrl, st_JsonRoot["tszKeyUrl"].asCString());
}
if (!st_JsonRoot["tszMapUrl"].isNull())
{
_tcscpy(pSt_ShortLink->tszMapUrl, st_JsonRoot["tszMapUrl"].asCString());
}
if (!st_JsonRoot["tszCvtUrl"].isNull())
{
_tcscpy(pSt_ShortLink->tszCvtUrl, st_JsonRoot["tszCvtUrl"].asCString());
}
if (!st_JsonRoot["tszCreateTime"].isNull())
{
_tcscpy(pSt_ShortLink->tszCreateTime, st_JsonRoot["tszCreateTime"].asCString());
}
if (!st_JsonRoot["nLength"].isNull())
{
pSt_ShortLink->nLength = st_JsonRoot["nLength"].asInt();
}
return XTRUE;
}
\ No newline at end of file
......@@ -26,5 +26,6 @@ public:
XBOOL ModuleProtocol_Parse_XLog(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_XLOGINFO* pSt_XLogInfo);
XBOOL ModuleProtocol_Parse_QRCode(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_QRCODE* pSt_QRCode);
XBOOL ModuleProtocol_Parse_SocketTest(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_SOCKETTEST* pSt_SocketTest);
XBOOL ModuleProtocol_Parse_ShortLink(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_SHORTLINK* pSt_ShortLink);
private:
};
\ No newline at end of file
......@@ -12,6 +12,7 @@ EXPORTS
ModuleProtocol_Packet_Log
ModuleProtocol_Packet_TestReport
ModuleProtocol_Packet_TestReply
ModuleProtocol_Packet_ShortLink
ModuleProtocol_Packet_P2PLan
ModuleProtocol_Packet_P2PWLan
ModuleProtocol_Packet_P2PUser
......@@ -24,4 +25,5 @@ EXPORTS
ModuleProtocol_Parse_ZIPCode
ModuleProtocol_Parse_XLog
ModuleProtocol_Parse_QRCode
ModuleProtocol_Parse_SocketTest
\ No newline at end of file
ModuleProtocol_Parse_SocketTest
ModuleProtocol_Parse_ShortLink
\ No newline at end of file
......@@ -67,6 +67,10 @@ extern "C" XBOOL ModuleProtocol_Packet_TestReply(XCHAR * ptszMsgBuffer, int* pIn
{
return m_ProtocolPacket.ModuleProtocol_Packet_TestReply(ptszMsgBuffer, pInt_MsgLen, xhToken);
}
extern "C" XBOOL ModuleProtocol_Packet_ShortLink(XCHAR * ptszMsgBuffer, int* pInt_MsgLen, XENGINE_SHORTLINK * pSt_ShortLink)
{
return m_ProtocolPacket.ModuleProtocol_Packet_ShortLink(ptszMsgBuffer, pInt_MsgLen, pSt_ShortLink);
}
extern "C" XBOOL ModuleProtocol_Packet_P2PLan(XCHAR * ptszMsgBuffer, int* pInt_MsgLen, XENGINE_P2XPPEER_PROTOCOL * **pppSt_ListClients, int nListCount)
{
return m_ProtocolPacket.ModuleProtocol_Packet_P2PLan(ptszMsgBuffer, pInt_MsgLen, pppSt_ListClients, nListCount);
......@@ -117,4 +121,8 @@ extern "C" XBOOL ModuleProtocol_Parse_QRCode(LPCXSTR lpszMsgBuffer, int nMsgLen,
extern "C" XBOOL ModuleProtocol_Parse_SocketTest(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_SOCKETTEST * pSt_SocketTest)
{
return m_ProtocolParse.ModuleProtocol_Parse_SocketTest(lpszMsgBuffer, nMsgLen, pSt_SocketTest);
}
extern "C" XBOOL ModuleProtocol_Parse_ShortLink(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_SHORTLINK * pSt_ShortLink)
{
return m_ProtocolParse.ModuleProtocol_Parse_ShortLink(lpszMsgBuffer, nMsgLen, pSt_ShortLink);
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册