gateway.h
1.62 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once
#include <common.h>
#include <proto_header.h>
#undef BIND_PROTO_CMD
#undef BIND_PROTO_CMD_NO_CB
#define BIND_PROTO_CMD(__cmd_id__, fun_name, proto_name)\
static const CMD_ID cli_##proto_name##_cmd = __cmd_id__
#define BIND_PROTO_CMD_NO_CB(__cmd_id__, fun_name, proto_name)\
static const CMD_ID cli_##proto_name##_cmd = __cmd_id__
#include <gateway_cmd.h>
#undef BIND_PROTO_CMD
#undef BIND_PROTO_CMD_NO_CB
class user_t;
#define GATEWAY_MSG_HANDLE_FUN_PAR el::lib_tcp_peer_info_t* fd_info, google::protobuf::Message* msg, user_t* user
DEF_MSG_HANDLE_FUN(gateway_t, GATEWAY)
class gateway_t : public el::lib_timer_base_t
{
public:
gateway_t();
virtual ~gateway_t();
static int time_out_new_day(void* owen, void* data);
static int time_out_one_sec(void* owen, void* data);
static int time_out_one_minute(void* owen, void* data);
int time_out_new_mon();
int time_out_new_week();
//登陆超时处理
uint32_t login_time_out_sec;
static int time_out_login(void* owen, void* data);
int init();
private:
int load_conf();
bool check_config(void);
void release();
int init_msg_map();
void release_msg_map();
//binding processing function
#undef BIND_PROTO_CMD
#undef BIND_PROTO_CMD_NO_CB
#define BIND_PROTO_CMD(__cmd_id__, fun_name, proto_name)\
int fun_name(GATEWAY_MSG_HANDLE_FUN_PAR)
#define BIND_PROTO_CMD_NO_CB(__cmd_id__, fun_name, proto_name)
#include <gateway_cmd.h>
#undef BIND_PROTO_CMD
#undef BIND_PROTO_CMD_NO_CB
public:
int on_recv(el::lib_tcp_peer_info_t* peer_fd_info, char* pdata, int len);
GATEWAY_MSG_MAP_T msg_map;
server_send_data_t send_msg_buf;
};
extern gateway_t* g_gateway;