-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathTcpServerMsgHandler.cpp
executable file
·41 lines (36 loc) · 1.1 KB
/
TcpServerMsgHandler.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "TcpServerMsgHandler.h"
#include "HttpRequest.h"
#include "LibeventLog.h"
static void callback_func(E_RESPONSE_TYPE type, void *data, unsigned int len, void *arg) {
switch (type) {
case RESPONSE_OK:
//LibeventLog::userLog("[response to user] res ok: ");
break;
case RESPONSE_ERROR:
LibeventLog::userLog("[response to user] res err: %d ", *((int*)data));
break;
case REQUEST_TIMEOUT:
LibeventLog::userLog("[response to user] request timeout.");
break;
case CONNECTION_EXCEPTION:
LibeventLog::userLog("[response to user] connection exception.");
break;
default:
LibeventLog::userLog("[response to user] unknown.");
break;
}
}
int TcpServerMsgHandler::processMessage(void *arg) {
char *buf = "post xml data";
char *code = "291";
char *usr_arg = "ssssssssssssssssssssssss";
HttpRequest *req = new HttpRequest((struct event_base *)arg);
int ret = req->postHttpRequest(buf, strlen(buf), callback_func, usr_arg);
if (ret != 0 ) {
LibeventLog::userLog("[postHttpRequest] error.");
delete req;
return -1;
}
req->autoRelease();
return 0;
}