-
Notifications
You must be signed in to change notification settings - Fork 9
/
event_list.h
178 lines (152 loc) · 3.44 KB
/
event_list.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
//
// Created by pojol on 2017/2/13.
//
#pragma once
// 后面用工具自动生成
//! 用于描述框架中用到的事件, 用户可以以此为模板在自己工程中建立一个event_list 用于工程中的事件描述
namespace block
{
namespace event {
enum block_event {
/*!
comment: Module初始化成功
args: nil
type: boardcast
res : int32_t module_id
**/
module_init_succ = 101,
/*!
comment: Module退出成功
args: nil
type: boardcast
res : int32_t module_id
**/
module_shut_succ,
/*!
comment: 创建一个接收器
args: int32_t module_id, string ip, int32_t port
type: dispatch
res : bool succ or fail, string reason
**/
tcp_make_acceptor = 2001,
/*!
comment: 创建一个连接器
args: module_id, ip, port
type: dispatch
res : bool succ or fail, string reason
**/
tcp_make_connector,
/*!
comment: 踢掉某个现有的连接
args: int32_t fd
type: dispatch
res : bool succ or fail, string reason
**/
tcp_kick_connect,
/*!
comment: 发送一条网络消息
args: int32_t fd, int32_t msgid, stream block
type: dispatch
res : nil
**/
tcp_send,
/*!
comment: 接收到一条网络消息
args: int32_t fd, int32_t msgid, stream block
type: listen
res : nil
**/
tcp_recv,
/*!
comment: 接收到一个新的连接(适用于 acceptor
args: int32_t fd
type: listen
res : nil
**/
tcp_new_connect,
/*!
comment: 连接被断开, 只有连接错误才会收到这条事件(服务器主动kick不会
args: int32_t fd
type: listen
res : int32_t fd, string reason
**/
tcp_dis_connect,
/*!
comment: 重新装载 Lua Script Module, 会走标准的退出和进入流程 init, shut 。即便持有状态也可以方便的热更
args: int32_t module_id
type: dispatch
res : bool succ
**/
script_reload = 2301,
/*!
comment: 建立一个新的Mysql连接
args: string host, string user, string password, string dbName, int32_t port, bool useCache
type: dispatch
res : bool succ
**/
db_connect = 2401,
/*!
comment: 执行一条sql语句
args: int32_t moduleID, string sql
type: dispatch
res : nil
**/
db_execSql,
/*!
comment: 创建一个实例
args: string tableName, table entityInfo
type: dispatch
res : entityInfo
**/
db_insert,
/*!
comment: 获取一个实例
args: int32_t moduleID, string field, int32_t entityID ( entityID == 0 then load all
type: dispatch
res : entityInfo
**/
db_load,
/*!
comment: 更新一个实例
args: string field, int32_t entityID, table entityDirty
type: dispatch
res : nil
**/
db_update,
db_callback,
node_init = 2501,
node_addModule,
node_rmvModule,
};
}
namespace rpc
{
enum rpc_event {
//! 凡是gsf集群内使用rpc交互的消息都应该定义在distributed区块
begin = 1001,
/*!
comment: 调整Node在Coordinator中的权重
args: int32_t node_id, string module_name, int32_t module_fature, int32_t +- weight
type: rpc
res : stream args, int32_t progress, bool succ
**/
coordinat_adjust_weight,
end = 1999,
};
}
namespace error
{
enum block_error
{
err_repeated_fd = -10000,
err_upper_limit_session,
err_socket_new,
err_socket_connect,
err_event_eof,
err_event_error,
err_event_timeout,
err_inet_pton,
err_distributed_node_repeat,
};
}
}