Skip to content

Commit a2a2785

Browse files
committed
added:sqlite supported
Now supports the configuration of sqlite or mysql database.
1 parent 7658886 commit a2a2785

File tree

22 files changed

+917
-120
lines changed

22 files changed

+917
-120
lines changed

XEngine_Source/StorageModule_Config/Config_Define.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ typedef struct tag_XEngine_ServerConfig
4949
}st_XLog;
5050
struct
5151
{
52+
TCHAR tszSQLFile[MAX_PATH];
5253
TCHAR tszSQLAddr[128];
5354
TCHAR tszSQLUser[128];
5455
TCHAR tszSQLPass[128];
55-
TCHAR tszDBName[128];
56+
TCHAR tszDBName[128];
5657
int nSQLPort;
58+
int nSQLType;
5759
}st_XSql;
5860
struct
5961
{

XEngine_Source/StorageModule_Config/Config_Json/Config_Json.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,20 @@ BOOL CConfig_Json::Config_Json_File(LPCTSTR lpszConfigFile,XENGINE_SERVERCONFIG
107107
pSt_ServerConfig->st_XLog.nMaxCount = st_JsonXLog["MaxCount"].asInt();
108108
pSt_ServerConfig->st_XLog.nLogLeave = st_JsonXLog["LogLeave"].asInt();
109109

110-
if (st_JsonRoot["XSql"].empty() || (4 != st_JsonRoot["XSql"].size()))
110+
if (st_JsonRoot["XSql"].empty() || (6 != st_JsonRoot["XSql"].size()))
111111
{
112112
Config_IsErrorOccur = TRUE;
113113
Config_dwErrorCode = ERROR_XENGINE_BLOGIC_CONFIG_JSON_XSQL;
114114
return FALSE;
115115
}
116116
Json::Value st_JsonXSql = st_JsonRoot["XSql"];
117+
118+
pSt_ServerConfig->st_XSql.nSQLType = st_JsonXSql["SQLType"].asInt();
117119
pSt_ServerConfig->st_XSql.nSQLPort = st_JsonXSql["SQLPort"].asInt();
118-
_tcscpy(pSt_ServerConfig->st_XSql.tszSQLAddr,st_JsonXSql["SQLAddr"].asCString());
119-
_tcscpy(pSt_ServerConfig->st_XSql.tszSQLUser,st_JsonXSql["SQLUser"].asCString());
120-
_tcscpy(pSt_ServerConfig->st_XSql.tszSQLPass,st_JsonXSql["SQLPass"].asCString());
120+
_tcscpy(pSt_ServerConfig->st_XSql.tszSQLAddr, st_JsonXSql["SQLAddr"].asCString());
121+
_tcscpy(pSt_ServerConfig->st_XSql.tszSQLUser, st_JsonXSql["SQLUser"].asCString());
122+
_tcscpy(pSt_ServerConfig->st_XSql.tszSQLPass, st_JsonXSql["SQLPass"].asCString());
123+
_tcscpy(pSt_ServerConfig->st_XSql.tszSQLFile, st_JsonXSql["SQLFile"].asCString());
121124

122125
if (st_JsonRoot["XStorage"].empty() || (3 != st_JsonRoot["XStorage"].size()))
123126
{

XEngine_Source/XEngine_P2XPComponents/XEngine_P2XPProtocol/P2XPProtocol_Define.h

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -232,33 +232,4 @@ extern "C" BOOL P2XPProtocol_UserMsg_RequestLan(CHAR *ptszMsgBuffer, int *pInt_L
232232
意思:是否成功
233233
备注:
234234
*********************************************************************/
235-
extern "C" BOOL P2XPProtocol_UserMsg_RequestHeartBeat(CHAR *ptszMsgBuffer, int *pInt_Len);
236-
/********************************************************************
237-
函数名称:P2XPProtocol_UserMsg_RequestQueryUser
238-
函数功能:查询用户是否在线封装协议函数
239-
参数.一:pSt_Client
240-
In/Out:In
241-
类型:数据结构指针
242-
可空:N
243-
意思:输入要查询的对方用户信息
244-
参数.二:ptszMsgBuffer
245-
In/Out:Out
246-
类型:字符指针
247-
可空:N
248-
意思:导出组好包的数据
249-
参数.三:pInt_Len
250-
In/Out:In
251-
类型:整数型指针
252-
可空:N
253-
意思:导出组好包的数据长度
254-
参数.四:wPacketSerial
255-
In/Out:In
256-
类型:无符号短整数型
257-
可空:Y
258-
意思:设置这个包的序列,可以不设置,服务器返回的包序列也是这个
259-
返回值
260-
类型:逻辑型
261-
意思:是否成功构造
262-
备注:XENGINE_P2XPIO_PROTOCOL 只需要填写tszDestUser 其他不用填写
263-
*********************************************************************/
264-
extern "C" BOOL P2XPProtocol_UserMsg_RequestQueryUser(XENGINE_P2XPPEER_PROTOCOL *pSt_Client, CHAR *ptszMsgBuffer, int *pInt_Len, WORD wPacketSerial = 0);
235+
extern "C" BOOL P2XPProtocol_UserMsg_RequestHeartBeat(CHAR *ptszMsgBuffer, int *pInt_Len);

XEngine_Source/XEngine_P2XPComponents/XEngine_P2XPProtocol/P2XPProtocol_Error.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#define ERROR_NETENGINE_P2XP_PROTOCOL_USERMSG_REQUESTHB_PARAMENT 0xB0F1020 //参数错误
1818
#define ERROR_NETENGINE_P2XP_PROTOCOL_USERMSG_REQUESTIONET_PARAMENT 0xB0F1030 //参数错误
1919
#define ERROR_NETENGINE_P2XP_PROTOCOL_USERMSG_REQUESTLIST_PARAMENT 0xB0F1040
20-
#define ERROR_NETENGINE_P2XP_PROTOCOL_USERMSG_REQUESTQUERYUSER_PARAMENT 0xB0F1050
2120
/************************************************************************/
2221
/* 服务协议错误表 */
2322
/************************************************************************/

XEngine_Source/XEngine_P2XPComponents/XEngine_P2XPProtocol/P2XPProtocol_UserMsg/P2XPProtocol_UserMsg.cpp

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -210,60 +210,6 @@ BOOL CP2XPProtocol_UserMsg::P2XPProtocol_UserMsg_RequestLan(TCHAR *ptszMsgBuffer
210210
return TRUE;
211211
}
212212
/********************************************************************
213-
函数名称:P2XPProtocol_UserMsg_RequestOpenIONet
214-
函数功能:查询用户是否在线封装协议函数
215-
参数.一:pSt_Client
216-
In/Out:In
217-
类型:数据结构指针
218-
可空:N
219-
意思:输入要查询的对方用户信息
220-
参数.二:ptszMsgBuffer
221-
In/Out:Out
222-
类型:字符指针
223-
可空:N
224-
意思:导出组好包的数据
225-
参数.三:pInt_Len
226-
In/Out:In
227-
类型:整数型指针
228-
可空:N
229-
意思:导出组好包的数据长度
230-
参数.四:wPacketSerial
231-
In/Out:In
232-
类型:无符号短整数型
233-
可空:Y
234-
意思:设置这个包的序列,可以不设置,服务器返回的包序列也是这个
235-
返回值
236-
类型:逻辑型
237-
意思:是否成功构造
238-
备注:XENGINE_P2XPIO_PROTOCOL 只需要填写tszDestUser 其他不用填写
239-
*********************************************************************/
240-
BOOL CP2XPProtocol_UserMsg::P2XPProtocol_UserMsg_RequestQueryUser(XENGINE_P2XPPEER_PROTOCOL *pSt_Client,TCHAR *ptszMsgBuffer, int *pInt_Len, WORD wPacketSerial /* = 0 */)
241-
{
242-
P2XPProtocol_IsErrorOccur = FALSE;
243-
244-
if ((NULL == ptszMsgBuffer) || (NULL == pInt_Len))
245-
{
246-
P2XPProtocol_IsErrorOccur = FALSE;
247-
P2XPProtocol_dwErrorCode = ERROR_NETENGINE_P2XP_PROTOCOL_USERMSG_REQUESTQUERYUSER_PARAMENT;
248-
return FALSE;
249-
}
250-
XENGINE_PROTOCOLHDR st_ProtocolHdr;
251-
memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR));
252-
253-
st_ProtocolHdr.wHeader = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_HEADER;
254-
st_ProtocolHdr.unOperatorType = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_P2XP;
255-
st_ProtocolHdr.byVersion = 1;
256-
st_ProtocolHdr.wTail = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_TAIL;
257-
st_ProtocolHdr.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_P2XP_REQUSERQUERY;
258-
st_ProtocolHdr.unPacketSize = 0;
259-
st_ProtocolHdr.byIsReply = TRUE;
260-
261-
*pInt_Len = st_ProtocolHdr.unPacketSize + sizeof(XENGINE_PROTOCOLHDR);
262-
memcpy(ptszMsgBuffer, &st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
263-
memcpy(ptszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), pSt_Client, sizeof(XENGINE_P2XPPEER_PROTOCOL));
264-
return TRUE;
265-
}
266-
/********************************************************************
267213
函数名称:P2XPProtocol_UserMsg_RequestHeartBeat
268214
函数功能:封装一个心跳请求的包
269215
参数.一:ptszMsgBuffer

XEngine_Source/XEngine_P2XPComponents/XEngine_P2XPProtocol/P2XPProtocol_UserMsg/P2XPProtocol_UserMsg.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class CP2XPProtocol_UserMsg
2020
BOOL P2XPProtocol_UserMsg_RequestLogin(XENGINE_P2XPPEER_PROTOCOL *pSt_ClientInfo, XENGINE_PROTOCOL_USERAUTH *pSt_UserLogin, TCHAR *ptszMsgBuffer, int *pInt_Len, WORD wPacketSerial = 0);
2121
BOOL P2XPProtocol_UserMsg_RequestConnect(XENGINE_P2XPIO_PROTOCOL*pSt_ClientIONet, TCHAR *ptszMsgBuffer, int *pInt_Len, WORD wPacketSerial = 0);
2222
BOOL P2XPProtocol_UserMsg_RequestLan(TCHAR *ptszMsgBuffer, int *pInt_Len, BOOL bWlan = FALSE, WORD wPacketSerial = 0);
23-
BOOL P2XPProtocol_UserMsg_RequestQueryUser(XENGINE_P2XPPEER_PROTOCOL *pSt_Client, TCHAR *ptszMsgBuffer, int *pInt_Len, WORD wPacketSerial = 0);
2423
BOOL P2XPProtocol_UserMsg_RequestHeartBeat(TCHAR *ptszMsgBuffer, int *pInt_Len);
2524
protected:
2625
private:

XEngine_Source/XEngine_P2XPComponents/XEngine_P2XPProtocol/XEngine_P2XPProtocol.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ EXPORTS
1111
P2XPProtocol_UserMsg_RequestLogin
1212
P2XPProtocol_UserMsg_RequestConnect
1313
P2XPProtocol_UserMsg_RequestLan
14-
P2XPProtocol_UserMsg_RequestQueryUser
1514
P2XPProtocol_UserMsg_RequestHeartBeat

XEngine_Source/XEngine_P2XPComponents/XEngine_P2XPProtocol/pch.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ extern "C" BOOL P2XPProtocol_UserMsg_RequestLan(TCHAR * ptszMsgBuffer, int* pInt
5656
{
5757
return m_UserMsg.P2XPProtocol_UserMsg_RequestLan(ptszMsgBuffer, pInt_Len, bWlan, wPacketSerial);
5858
}
59-
extern "C" BOOL P2XPProtocol_UserMsg_RequestQueryUser(XENGINE_P2XPPEER_PROTOCOL * pSt_Client, TCHAR * ptszMsgBuffer, int* pInt_Len, WORD wPacketSerial)
60-
{
61-
return m_UserMsg.P2XPProtocol_UserMsg_RequestQueryUser(pSt_Client, ptszMsgBuffer, pInt_Len, wPacketSerial);
62-
}
6359
extern "C" BOOL P2XPProtocol_UserMsg_RequestHeartBeat(CHAR * ptszMsgBuffer, int* pInt_Len)
6460
{
6561
return m_UserMsg.P2XPProtocol_UserMsg_RequestHeartBeat(ptszMsgBuffer, pInt_Len);

XEngine_Source/XEngine_StorageApp/StorageApp_Hdr.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ using namespace std;
6161
#define STORAGE_NETTYPE_HTTPCENTER 3
6262

6363
extern BOOL bIsRun;
64-
extern BOOL bIsSQL;
6564
extern XLOG xhLog;
6665

6766
extern XNETHANDLE xhHBDownload;

XEngine_Source/XEngine_StorageApp/StorageApp_UPLoader.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,18 @@ BOOL XEngine_Task_HttpUPLoader(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, in
138138
//验证HASH值
139139
if (XEngine_APPHelp_VerHash(lpszClientAddr, tszFileDir, st_ProtocolFile.st_ProtocolFile.tszFileHash, pptszListHdr, nHdrCount))
140140
{
141-
if (bIsSQL)
141+
if (0 != st_ServiceCfg.st_XSql.nSQLType)
142142
{
143-
if (XStorageSQL_File_FileInsert(&st_ProtocolFile))
143+
BOOL bRet = FALSE;
144+
if (1 == st_ServiceCfg.st_XSql.nSQLType)
145+
{
146+
bRet = XStorageSQL_File_FileInsert(&st_ProtocolFile);
147+
}
148+
else
149+
{
150+
bRet = XStorage_SQLite_FileInsert(&st_ProtocolFile);
151+
}
152+
if (bRet)
144153
{
145154
if (st_ServiceCfg.st_XProxy.st_XProxyPass.bUPPass)
146155
{

0 commit comments

Comments
 (0)