66#pragma comment(lib,"x86/XEngine_BaseLib/XEngine_BaseLib")
77#pragma comment(lib,"x86/XEngine_NetHelp/NetHelp_APIClient")
88#pragma comment(lib,"../../XEngine_Source/Debug/jsoncpp")
9- #else
9+ #endif
1010#include < stdio.h>
1111#include < stdlib.h>
1212#include < string.h>
13- #endif
1413#include < json/json.h>
1514#include < XEngine_Include/XEngine_CommHdr.h>
15+ #include < XEngine_Include/XEngine_Types.h>
1616#include < XEngine_Include/XEngine_ProtocolHdr.h>
1717#include < XEngine_Include/XEngine_BaseLib/BaseLib_Define.h>
1818#include < XEngine_Include/XEngine_BaseLib/BaseLib_Error.h>
1919#include < XEngine_Include/XEngine_NetHelp/APIClient_Define.h>
2020#include < XEngine_Include/XEngine_NetHelp/APIClient_Error.h>
2121#include " ../../XEngine_Source/XQueue_ProtocolHdr.h"
2222
23- // g++ -std=c++17 -Wall -g MQCore_HTTPApp.cpp -o MQCore_HTTPApp.exe -I ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_NetHelp -L ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -lXEngine_BaseLib -lNetHelp_APIClient -ljsoncpp
23+ // g++ -std=c++17 -Wall -g MQCore_HTTPApp.cpp -o MQCore_HTTPApp.exe -I ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_NetHelp -L ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -lXEngine_BaseLib -lNetHelp_APIClient -ljsoncpp -Wl,-rpath=../../XEngine_Source/XEngine_ThirdPart/jsoncpp,--disable-new-dtags
2424
25- SOCKET m_Socket;
25+ XSOCKET m_Socket;
2626XNETHANDLE xhToken = 0 ;
27- LPCTSTR lpszKey = _T (" XEngine_Notify" ); // 主题
28- LPCTSTR lpszPostUrl = _T (" http://127.0.0.1:5201" );
27+ LPCXSTR lpszKey = _X (" XEngine_Notify" ); // 主题
28+ LPCXSTR lpszPostUrl = _X (" http://127.0.0.1:5201" );
2929
3030void MQ_Authorize ()
3131{
3232 int nLen = 0 ;
33- TCHAR tszMsgBuffer[2048 ];
33+ XCHAR tszMsgBuffer[2048 ];
3434 memset (tszMsgBuffer, ' \0 ' , sizeof (tszMsgBuffer));
3535
3636 Json::Value st_JsonRoot;
@@ -47,13 +47,13 @@ void MQ_Authorize()
4747 nLen = st_JsonRoot.toStyledString ().length ();
4848 memcpy (tszMsgBuffer, st_JsonRoot.toStyledString ().c_str (), nLen);
4949
50- TCHAR * ptszMsgBody = NULL ;
51- if (!APIClient_Http_Request (_T (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody, &nLen))
50+ XCHAR * ptszMsgBody = NULL ;
51+ if (!APIClient_Http_Request (_X (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody, &nLen))
5252 {
53- printf (" 发送投递失败!\n " );
53+ _xtprintf (" 发送投递失败!\n " );
5454 return ;
5555 }
56- printf (" MQ_Authorize:%s\n " , ptszMsgBody);
56+ _xtprintf (" MQ_Authorize:%s\n " , ptszMsgBody);
5757
5858 JSONCPP_STRING st_JsonError;
5959 Json::CharReaderBuilder st_ReaderBuilder;
@@ -72,64 +72,64 @@ void MQ_Authorize()
7272void MQ_UNRead ()
7373{
7474 int nLen = 0 ;
75- TCHAR tszMsgBuffer[2048 ];
75+ XCHAR tszMsgBuffer[2048 ];
7676 memset (tszMsgBuffer, ' \0 ' , sizeof (tszMsgBuffer));
7777
7878 Json::Value st_JsonRoot;
7979 Json::Value st_JsonMQProtocol;
8080 st_JsonRoot[" unOperatorType" ] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
8181 st_JsonRoot[" unOperatorCode" ] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQUNREAD;
8282 st_JsonRoot[" byVersion" ] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
83- st_JsonRoot[" xhToken" ] = xhToken;
83+ st_JsonRoot[" xhToken" ] = (Json::Value::UInt64) xhToken;
8484
8585 st_JsonMQProtocol[" tszMQKey" ] = " " ; // 所有未读
8686 st_JsonRoot[" st_MQProtocol" ] = st_JsonMQProtocol;
8787
8888 nLen = st_JsonRoot.toStyledString ().length ();
8989 memcpy (tszMsgBuffer, st_JsonRoot.toStyledString ().c_str (), nLen);
9090
91- TCHAR * ptszMsgBody = NULL ;
92- if (!APIClient_Http_Request (_T (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody))
91+ XCHAR * ptszMsgBody = NULL ;
92+ if (!APIClient_Http_Request (_X (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody))
9393 {
94- printf (" 发送投递失败!\n " );
94+ _xtprintf (" 发送投递失败!\n " );
9595 return ;
9696 }
97- printf (" MQ_UNRead:%s\n " , ptszMsgBody);
97+ _xtprintf (" MQ_UNRead:%s\n " , ptszMsgBody);
9898 BaseLib_OperatorMemory_FreeCStyle ((XPPMEM)&ptszMsgBody);
9999}
100100void MQ_Create ()
101101{
102102 int nLen = 0 ;
103- TCHAR tszMsgBuffer[2048 ];
103+ XCHAR tszMsgBuffer[2048 ];
104104 memset (tszMsgBuffer, ' \0 ' , sizeof (tszMsgBuffer));
105105
106106 Json::Value st_JsonRoot;
107107 Json::Value st_JsonMQProtocol;
108108 st_JsonRoot[" unOperatorType" ] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
109109 st_JsonRoot[" unOperatorCode" ] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICCREATE;
110110 st_JsonRoot[" byVersion" ] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
111- st_JsonRoot[" xhToken" ] = xhToken;
111+ st_JsonRoot[" xhToken" ] = (Json::Value::UInt64) xhToken;
112112
113113 st_JsonMQProtocol[" tszMQKey" ] = lpszKey;
114114 st_JsonRoot[" st_MQProtocol" ] = st_JsonMQProtocol;
115115
116116 nLen = st_JsonRoot.toStyledString ().length ();
117117 memcpy (tszMsgBuffer, st_JsonRoot.toStyledString ().c_str (), nLen);
118118
119- TCHAR * ptszMsgBody = NULL ;
120- if (!APIClient_Http_Request (_T (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody))
119+ XCHAR * ptszMsgBody = NULL ;
120+ if (!APIClient_Http_Request (_X (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody))
121121 {
122- printf (" 发送投递失败!\n " );
122+ _xtprintf (" 发送投递失败!\n " );
123123 return ;
124124 }
125- printf (" MQ_Create:%s\n " , ptszMsgBody);
125+ _xtprintf (" MQ_Create:%s\n " , ptszMsgBody);
126126 BaseLib_OperatorMemory_FreeCStyle ((XPPMEM)&ptszMsgBody);
127127}
128128
129- void MQ_Post (LPCTSTR lpszMsgBuffer)
129+ void MQ_Post (LPCXSTR lpszMsgBuffer)
130130{
131131 int nLen = 0 ;
132- TCHAR tszMsgBuffer[2048 ];
132+ XCHAR tszMsgBuffer[2048 ];
133133 memset (tszMsgBuffer, ' \0 ' , sizeof (tszMsgBuffer));
134134
135135 Json::Value st_JsonRoot;
@@ -138,7 +138,7 @@ void MQ_Post(LPCTSTR lpszMsgBuffer)
138138 st_JsonRoot[" unOperatorType" ] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
139139 st_JsonRoot[" unOperatorCode" ] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQPOST;
140140 st_JsonRoot[" byVersion" ] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_STRING;
141- st_JsonRoot[" xhToken" ] = xhToken;
141+ st_JsonRoot[" xhToken" ] = (Json::Value::UInt64) xhToken;
142142
143143 st_JsonMQProtocol[" tszMQKey" ] = lpszKey;
144144 st_JsonMQProtocol[" nSerial" ] = 0 ; // 序列号,0服务会自动处理
@@ -155,20 +155,20 @@ void MQ_Post(LPCTSTR lpszMsgBuffer)
155155 nLen = st_JsonRoot.toStyledString ().length ();
156156 memcpy (tszMsgBuffer, st_JsonRoot.toStyledString ().c_str (), nLen);
157157
158- TCHAR * ptszMsgBody = NULL ;
159- if (!APIClient_Http_Request (_T (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody))
158+ XCHAR * ptszMsgBody = NULL ;
159+ if (!APIClient_Http_Request (_X (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody))
160160 {
161- printf (" 发送投递失败!\n " );
161+ _xtprintf (" 发送投递失败!\n " );
162162 return ;
163163 }
164- printf (" MQ_Post:%s\n " , ptszMsgBody);
164+ _xtprintf (" MQ_Post:%s\n " , ptszMsgBody);
165165 BaseLib_OperatorMemory_FreeCStyle ((XPPMEM)&ptszMsgBody);
166166}
167167
168168void MQ_BindTopic ()
169169{
170170 int nLen = 0 ;
171- TCHAR tszMsgBuffer[2048 ];
171+ XCHAR tszMsgBuffer[2048 ];
172172 memset (tszMsgBuffer, ' \0 ' , sizeof (tszMsgBuffer));
173173
174174 Json::Value st_JsonRoot;
@@ -177,7 +177,7 @@ void MQ_BindTopic()
177177 st_JsonRoot[" unOperatorType" ] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
178178 st_JsonRoot[" unOperatorCode" ] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICBIND;
179179 st_JsonRoot[" byVersion" ] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
180- st_JsonRoot[" xhToken" ] = xhToken;
180+ st_JsonRoot[" xhToken" ] = (Json::Value::UInt64) xhToken;
181181
182182 st_JsonMQProtocol[" nSerial" ] = 1 ; // 设置为1开始读取
183183 st_JsonMQProtocol[" tszMQKey" ] = lpszKey;
@@ -186,19 +186,19 @@ void MQ_BindTopic()
186186 nLen = st_JsonRoot.toStyledString ().length ();
187187 memcpy (tszMsgBuffer, st_JsonRoot.toStyledString ().c_str (), nLen);
188188
189- TCHAR * ptszMsgBody = NULL ;
190- if (!APIClient_Http_Request (_T (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody))
189+ XCHAR * ptszMsgBody = NULL ;
190+ if (!APIClient_Http_Request (_X (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody))
191191 {
192- printf (" 发送投递失败!\n " );
192+ _xtprintf (" 发送投递失败!\n " );
193193 return ;
194194 }
195- printf (" MQ_GetNumber:%s\n " , ptszMsgBody);
195+ _xtprintf (" MQ_GetNumber:%s\n " , ptszMsgBody);
196196 BaseLib_OperatorMemory_FreeCStyle ((XPPMEM)&ptszMsgBody);
197197}
198198void MQ_Get ()
199199{
200200 int nLen = 0 ;
201- TCHAR tszMsgBuffer[2048 ];
201+ XCHAR tszMsgBuffer[2048 ];
202202 memset (tszMsgBuffer, ' \0 ' , sizeof (tszMsgBuffer));
203203
204204 Json::Value st_JsonRoot;
@@ -207,7 +207,7 @@ void MQ_Get()
207207 st_JsonRoot[" unOperatorType" ] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
208208 st_JsonRoot[" unOperatorCode" ] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQGET;
209209 st_JsonRoot[" byVersion" ] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
210- st_JsonRoot[" xhToken" ] = xhToken;
210+ st_JsonRoot[" xhToken" ] = (Json::Value::UInt64) xhToken;
211211
212212 st_JsonMQProtocol[" tszMQKey" ] = lpszKey;
213213
@@ -216,19 +216,19 @@ void MQ_Get()
216216 nLen = st_JsonRoot.toStyledString ().length ();
217217 memcpy (tszMsgBuffer, st_JsonRoot.toStyledString ().c_str (), nLen);
218218
219- TCHAR * ptszMsgBody = NULL ;
220- if (!APIClient_Http_Request (_T (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody))
219+ XCHAR * ptszMsgBody = NULL ;
220+ if (!APIClient_Http_Request (_X (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody))
221221 {
222- printf (" 发送投递失败!\n " );
222+ _xtprintf (" 发送投递失败!\n " );
223223 return ;
224224 }
225- printf (" MQ_Get:%s\n " , ptszMsgBody);
225+ _xtprintf (" MQ_Get:%s\n " , ptszMsgBody);
226226 BaseLib_OperatorMemory_FreeCStyle ((XPPMEM)&ptszMsgBody);
227227}
228228void MQ_ModifyMsg ()
229229{
230230 int nLen = 0 ;
231- TCHAR tszMsgBuffer[2048 ];
231+ XCHAR tszMsgBuffer[2048 ];
232232 memset (tszMsgBuffer, ' \0 ' , sizeof (tszMsgBuffer));
233233
234234 Json::Value st_JsonRoot;
@@ -237,7 +237,7 @@ void MQ_ModifyMsg()
237237 st_JsonRoot[" unOperatorType" ] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
238238 st_JsonRoot[" unOperatorCode" ] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQMSGMODIFY;
239239 st_JsonRoot[" byVersion" ] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
240- st_JsonRoot[" xhToken" ] = xhToken;
240+ st_JsonRoot[" xhToken" ] = (Json::Value::UInt64) xhToken;
241241
242242 st_JsonMQProtocol[" tszMQKey" ] = lpszKey;
243243 st_JsonMQProtocol[" nSerial" ] = 1 ; // 序列号
@@ -256,19 +256,19 @@ void MQ_ModifyMsg()
256256 nLen = st_JsonRoot.toStyledString ().length ();
257257 memcpy (tszMsgBuffer, st_JsonRoot.toStyledString ().c_str (), nLen);
258258
259- TCHAR * ptszMsgBody = NULL ;
260- if (!APIClient_Http_Request (_T (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody))
259+ XCHAR * ptszMsgBody = NULL ;
260+ if (!APIClient_Http_Request (_X (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody))
261261 {
262- printf (" 发送投递失败!\n " );
262+ _xtprintf (" 发送投递失败!\n " );
263263 return ;
264264 }
265- printf (" MQ_ModifyMsg:%s\n " , ptszMsgBody);
265+ _xtprintf (" MQ_ModifyMsg:%s\n " , ptszMsgBody);
266266 BaseLib_OperatorMemory_FreeCStyle ((XPPMEM)&ptszMsgBody);
267267}
268268void MQ_ModifyTopic ()
269269{
270270 int nLen = 0 ;
271- TCHAR tszMsgBuffer[2048 ];
271+ XCHAR tszMsgBuffer[2048 ];
272272 memset (tszMsgBuffer, ' \0 ' , sizeof (tszMsgBuffer));
273273
274274 Json::Value st_JsonRoot;
@@ -277,7 +277,7 @@ void MQ_ModifyTopic()
277277 st_JsonRoot[" unOperatorType" ] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
278278 st_JsonRoot[" unOperatorCode" ] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICMODIFY;
279279 st_JsonRoot[" byVersion" ] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
280- st_JsonRoot[" xhToken" ] = xhToken;
280+ st_JsonRoot[" xhToken" ] = (Json::Value::UInt64) xhToken;
281281
282282 st_JsonMQProtocol[" tszMQKey" ] = lpszKey;
283283
@@ -291,19 +291,19 @@ void MQ_ModifyTopic()
291291 nLen = st_JsonRoot.toStyledString ().length ();
292292 memcpy (tszMsgBuffer, st_JsonRoot.toStyledString ().c_str (), nLen);
293293
294- TCHAR * ptszMsgBody = NULL ;
295- if (!APIClient_Http_Request (_T (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody))
294+ XCHAR * ptszMsgBody = NULL ;
295+ if (!APIClient_Http_Request (_X (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody))
296296 {
297- printf (" 发送投递失败!\n " );
297+ _xtprintf (" 发送投递失败!\n " );
298298 return ;
299299 }
300- printf (" MQ_ModifyTopic:%s\n " , ptszMsgBody);
300+ _xtprintf (" MQ_ModifyTopic:%s\n " , ptszMsgBody);
301301 BaseLib_OperatorMemory_FreeCStyle ((XPPMEM)&ptszMsgBody);
302302}
303303void MQ_Delete ()
304304{
305305 int nLen = 0 ;
306- TCHAR tszMsgBuffer[2048 ];
306+ XCHAR tszMsgBuffer[2048 ];
307307 memset (tszMsgBuffer, ' \0 ' , sizeof (tszMsgBuffer));
308308
309309 Json::Value st_JsonRoot;
@@ -312,21 +312,21 @@ void MQ_Delete()
312312 st_JsonRoot[" unOperatorType" ] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_XMQ;
313313 st_JsonRoot[" unOperatorCode" ] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQTOPICDELETE;
314314 st_JsonRoot[" byVersion" ] = ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE_JSON;
315- st_JsonRoot[" xhToken" ] = xhToken;
315+ st_JsonRoot[" xhToken" ] = (Json::Value::UInt64) xhToken;
316316
317317 st_JsonMQProtocol[" tszMQKey" ] = " XEngine_Modify" ;
318318 st_JsonRoot[" st_MQProtocol" ] = st_JsonMQProtocol;
319319
320320 nLen = st_JsonRoot.toStyledString ().length ();
321321 memcpy (tszMsgBuffer, st_JsonRoot.toStyledString ().c_str (), nLen);
322322
323- TCHAR * ptszMsgBody = NULL ;
324- if (!APIClient_Http_Request (_T (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody))
323+ XCHAR * ptszMsgBody = NULL ;
324+ if (!APIClient_Http_Request (_X (" POST" ), lpszPostUrl, tszMsgBuffer, NULL , &ptszMsgBody))
325325 {
326- printf (" 发送投递失败!\n " );
326+ _xtprintf (" 发送投递失败!\n " );
327327 return ;
328328 }
329- printf (" MQ_Delete:%s\n " , ptszMsgBody);
329+ _xtprintf (" MQ_Delete:%s\n " , ptszMsgBody);
330330 BaseLib_OperatorMemory_FreeCStyle ((XPPMEM)&ptszMsgBody);
331331}
332332
0 commit comments