天佐.追日靴  tianzuo.Zhuiri
可靠UDP传输 reliable UDP transmission
Loading...
Searching...
No Matches
tianzuo.Zhuiri.h
Go to the documentation of this file.
1
2// *@file tianzuo.Zhuiri.h
3// *@brief 天佐.追日靴 (tianzuo.Zhuiri)
4// *@version 1.0
5// *@section LICENSE Copyright © 2003-2103 郑天佐 Corporation
6// *@author 郑天佐 (zhengtianzuo)
7// *@date 2013-4-3
8#pragma once
9#include <string.h>
10
11// 通讯消息 (communication message)
12const int Zhuiri_heart = 0x00001000;
13const int Zhuiri_heart_timeout = 0x00001001;
14const int Zhuiri_content_size = 492;
15
18typedef struct Zhuiri_data_tag {
20 m_ip_adrs = 0;
21 m_port = 0;
22 m_function = 0;
23 m_sign = 0;
24 m_index = 0;
25 m_send_time = 0;
26 m_send_size = 0;
27 memset(m_data, 0, Zhuiri_content_size);
28 }
29
31 m_ip_adrs = other.m_ip_adrs;
32 m_port = other.m_port;
33 m_function = other.m_function;
34 m_sign = other.m_sign;
35 m_index = other.m_index;
36 m_send_time = other.m_send_time;
37 m_send_size = other.m_send_size;
38 memcpy(m_data, other.m_data, Zhuiri_content_size);
39 }
40
43
44 int get_ip_adrs() const {
45 return m_ip_adrs;
46 }
47
48 void set_ip_adrs(int ip_adrs) {
49 m_ip_adrs = ip_adrs;
50 }
51
52 int get_port() const {
53 return m_port;
54 }
55
56 void set_port(int port) {
57 m_port = port;
58 }
59
60 int get_function() const {
61 return m_function;
62 }
63
64 void set_function(int function) {
65 m_function = function;
66 }
67
68 int get_sign() const {
69 return m_sign;
70 }
71
72 void set_sign(int sign) {
73 m_sign = sign;
74 }
75
76 int get_index() const {
77 return m_index;
78 }
79
80 void set_index(int index) {
81 m_index = index;
82 }
83
84 int get_send_time() const {
85 return m_send_time;
86 }
87
88 void set_send_time(int send_time) {
89 m_send_time = send_time;
90 }
91
92 int get_send_size() const {
93 return m_send_size;
94 }
95
96 void set_send_size(int send_size) {
97 m_send_size = send_size;
98 }
99
100private:
101 int m_ip_adrs;
102 int m_port;
103 int m_function;
104 int m_sign;
105 int m_index;
106 int m_send_time;
107 int m_send_size;
108
109public:
113
116typedef struct Zhuiri_data_pkg_tag {
118 m_send_data = NULL;
119 m_Zhuiri = NULL;
120 m_user_data = NULL;
121 memset(&m_data, 0, Zhuiri_data_total_size);
122 }
123
125 m_send_data = other.m_send_data;
126 m_Zhuiri = other.m_Zhuiri;
127 m_user_data = other.m_user_data;
128 m_data = other.m_data;
129 }
130
131 char *&get_send_data() {
132 return m_send_data;
133 }
134
135 void set_send_data(char* send_data) {
136 m_send_data = send_data;
137 }
138
139 void *&get_Zhuiri() {
140 return m_Zhuiri;
141 }
142
143 void set_Zhuiri(void *Zhuiri) {
144 m_Zhuiri = Zhuiri;
145 }
146
147 void *&get_user_data() {
148 return m_user_data;
149 }
150
151 void set_user_data(void *user_data) {
152 m_user_data = user_data;
153 }
154
156
157private:
158 char *m_send_data;
159 void *m_Zhuiri;
160 void *m_user_data;
163
167 int get_id() {
168 return m_user_id;
169 }
170
171 void set_id(int user_id) {
172 m_user_id = user_id;
173 }
174
176 return m_user_type;
177 }
178
179 void set_user_type(int user_type) {
180 m_user_type = user_type;
181 }
182
186
191 m_user_id = 0;
192 m_ip_adrs = 0;
193 m_port = 0;
194 m_user_type = 0;
195 m_send_time = 0;
196 memset(&stuSendHeart, 0, sizeof(Zhuiri_pkg_send_heart_struct));
197 }
198
199 Zhuiri_pkg_recv_heart_tag(int user_id, int ip_adrs, int port, int user_type, int send_time, int sender_user_id, int sender_user_type) {
200 m_user_id = user_id;
201 m_ip_adrs = ip_adrs;
202 m_port = port;
203 m_user_type = user_type;
204 m_send_time = send_time;
205 stuSendHeart.m_user_id = sender_user_id;
206 stuSendHeart.m_user_type = sender_user_type;
207 }
208
209 int get_user_id() const {
210 return m_user_id;
211 }
212
213 void set_user_id(int user_id) {
214 m_user_id = user_id;
215 }
216
217 int get_ip_adrs() const {
218 return m_ip_adrs;
219 }
220
221 void set_ip_adrs(int ip_adrs) {
222 m_ip_adrs = ip_adrs;
223 }
224
225 int get_port() const {
226 return m_port;
227 }
228
229 void set_port(int port) {
230 m_port = port;
231 }
232
233 int get_user_type() const {
234 return m_user_type;
235 }
236
237 void set_user_type(int user_type) {
238 m_user_type = user_type;
239 }
240
241 int get_send_time() const {
242 return m_send_time;
243 }
244
245 void set_send_time(int send_time) {
246 m_send_time = send_time;
247 }
248
250
251private:
252 int m_user_id;
253 int m_ip_adrs;
254 int m_port;
255 int m_user_type;
256 int m_send_time;
258
267
275
289
298
299// 回调函数 (call back)
300typedef unsigned(*Zhuiri_callback)(const void *context, const Zhuiri_data_pkg_pointer pData);
数据包结构
Definition tianzuo.Zhuiri.h:116
void set_user_data(void *user_data)
Definition tianzuo.Zhuiri.h:151
void *& get_user_data()
Definition tianzuo.Zhuiri.h:147
void set_Zhuiri(void *Zhuiri)
Definition tianzuo.Zhuiri.h:143
Zhuiri_data_struct m_data
结构内容 (structural content)
Definition tianzuo.Zhuiri.h:155
Zhuiri_data_pkg_tag()
Definition tianzuo.Zhuiri.h:117
char *& get_send_data()
Definition tianzuo.Zhuiri.h:131
Zhuiri_data_pkg_tag(const Zhuiri_data_pkg_tag &other)
Definition tianzuo.Zhuiri.h:124
void set_send_data(char *send_data)
Definition tianzuo.Zhuiri.h:135
void *& get_Zhuiri()
Definition tianzuo.Zhuiri.h:139
数据包结构
Definition tianzuo.Zhuiri.h:18
Zhuiri_data_tag(const Zhuiri_data_tag &other)
Definition tianzuo.Zhuiri.h:30
int get_function() const
Definition tianzuo.Zhuiri.h:60
int get_sign() const
Definition tianzuo.Zhuiri.h:68
Zhuiri_data_tag()
Definition tianzuo.Zhuiri.h:19
int get_index() const
Definition tianzuo.Zhuiri.h:76
int get_port() const
Definition tianzuo.Zhuiri.h:52
~Zhuiri_data_tag()
Definition tianzuo.Zhuiri.h:41
int get_ip_adrs() const
Definition tianzuo.Zhuiri.h:44
void set_port(int port)
Definition tianzuo.Zhuiri.h:56
void set_send_size(int send_size)
Definition tianzuo.Zhuiri.h:96
void set_sign(int sign)
Definition tianzuo.Zhuiri.h:72
void set_function(int function)
Definition tianzuo.Zhuiri.h:64
char m_data[Zhuiri_content_size]
具体内容 (concrete content)
Definition tianzuo.Zhuiri.h:110
int get_send_time() const
Definition tianzuo.Zhuiri.h:84
void set_ip_adrs(int ip_adrs)
Definition tianzuo.Zhuiri.h:48
void set_send_time(int send_time)
Definition tianzuo.Zhuiri.h:88
int get_send_size() const
Definition tianzuo.Zhuiri.h:92
void set_index(int index)
Definition tianzuo.Zhuiri.h:80
心跳包接收结构
Definition tianzuo.Zhuiri.h:189
void set_send_time(int send_time)
Definition tianzuo.Zhuiri.h:245
int get_send_time() const
Definition tianzuo.Zhuiri.h:241
int get_user_id() const
Definition tianzuo.Zhuiri.h:209
void set_ip_adrs(int ip_adrs)
Definition tianzuo.Zhuiri.h:221
int get_port() const
Definition tianzuo.Zhuiri.h:225
Zhuiri_pkg_recv_heart_tag()
Definition tianzuo.Zhuiri.h:190
int get_user_type() const
Definition tianzuo.Zhuiri.h:233
Zhuiri_pkg_send_heart_struct stuSendHeart
发送心跳包信息 (send heartbeat packet information)
Definition tianzuo.Zhuiri.h:249
void set_port(int port)
Definition tianzuo.Zhuiri.h:229
void set_user_id(int user_id)
Definition tianzuo.Zhuiri.h:213
Zhuiri_pkg_recv_heart_tag(int user_id, int ip_adrs, int port, int user_type, int send_time, int sender_user_id, int sender_user_type)
Definition tianzuo.Zhuiri.h:199
void set_user_type(int user_type)
Definition tianzuo.Zhuiri.h:237
int get_ip_adrs() const
Definition tianzuo.Zhuiri.h:217
心跳包发送结构
Definition tianzuo.Zhuiri.h:166
int m_user_type
用户类型 (user type)
Definition tianzuo.Zhuiri.h:184
void set_id(int user_id)
Definition tianzuo.Zhuiri.h:171
int m_user_id
用户ID (user ID)
Definition tianzuo.Zhuiri.h:183
void set_user_type(int user_type)
Definition tianzuo.Zhuiri.h:179
int get_user_type()
Definition tianzuo.Zhuiri.h:175
int get_id()
Definition tianzuo.Zhuiri.h:167
const int Zhuiri_heart
心跳包信息 (Heartbeat packet information)
Definition tianzuo.Zhuiri.h:12
struct Zhuiri_data_tag * Zhuiri_data_pointer
unsigned(* Zhuiri_callback)(const void *context, const Zhuiri_data_pkg_pointer pData)
Definition tianzuo.Zhuiri.h:300
Zhuiri_data_status
Definition tianzuo.Zhuiri.h:269
@ Zhuiri_data_status_retrying
重发中 (retrying)
Definition tianzuo.Zhuiri.h:272
@ Zhuiri_data_status_normal
正常 (normal)
Definition tianzuo.Zhuiri.h:271
@ Zhuiri_data_status_none
空闲 (free)
Definition tianzuo.Zhuiri.h:270
@ Zhuiri_data_status_failed
失败 (failed)
Definition tianzuo.Zhuiri.h:273
struct Zhuiri_pkg_recv_heart_tag Zhuiri_pkg_recv_heart_struct
Zhuiri_data_sign
Definition tianzuo.Zhuiri.h:260
@ Zhuiri_data_sign_processing
处理中 (processing)
Definition tianzuo.Zhuiri.h:263
@ Zhuiri_data_sign_response
回应消息 (response)
Definition tianzuo.Zhuiri.h:264
@ Zhuiri_data_sign_none
无标识 (no sign)
Definition tianzuo.Zhuiri.h:261
@ Zhuiri_data_sign_reliable
可靠 (reliable)
Definition tianzuo.Zhuiri.h:262
@ Zhuiri_data_sign_heart
心跳包 (heart)
Definition tianzuo.Zhuiri.h:265
const int Zhuiri_heart_timeout
心跳包超时信息 (Heartbeat packet timeout information)
Definition tianzuo.Zhuiri.h:13
struct Zhuiri_data_tag Zhuiri_data_struct
struct Zhuiri_pkg_recv_heart_tag * Zhuiri_pkg_recv_heart_pointer
struct Zhuiri_pkg_send_heart_tag Zhuiri_pkg_send_heart_struct
struct Zhuiri_data_pkg_tag * Zhuiri_data_pkg_pointer
struct Zhuiri_pkg_send_heart_tag * Zhuiri_pkg_send_heart_pointer
const int Zhuiri_content_size
内容大小 (content size)
Definition tianzuo.Zhuiri.h:14
const int Zhuiri_data_pkg_total_size
消息内容长度 (message content length) = 544
Definition tianzuo.Zhuiri.h:162
const int Zhuiri_data_total_size
消息内容长度 (message content length) = 520
Definition tianzuo.Zhuiri.h:112
struct Zhuiri_data_pkg_tag Zhuiri_data_pkg_struct
Zhuiri_queue_error_code
Definition tianzuo.Zhuiri.h:291
@ Zhuiri_queue_error_code_no_data
无数据 (no data)
Definition tianzuo.Zhuiri.h:296
@ Zhuiri_queue_error_code_success
正确的值 (success)
Definition tianzuo.Zhuiri.h:292
@ Zhuiri_queue_error_code_out_of_cache
超出缓冲 (out f cache)
Definition tianzuo.Zhuiri.h:294
@ Zhuiri_queue_error_code_out_of_memory
内存溢出 (out of memory)
Definition tianzuo.Zhuiri.h:295
@ Zhuiri_queue_error_code_invalid_value
无效的值 (invalid value)
Definition tianzuo.Zhuiri.h:293
Zhuiri_error_code
Definition tianzuo.Zhuiri.h:277
@ Zhuiri_error_code_success
正确的值 (success)
Definition tianzuo.Zhuiri.h:278
@ Zhuiri_error_code_user_exit
自行退出 (user exit)
Definition tianzuo.Zhuiri.h:287
@ Zhuiri_error_code_out_of_cache
超出缓冲最大值 (out f cache)
Definition tianzuo.Zhuiri.h:283
@ Zhuiri_error_code_no_rights
效验未通过 (no rights)
Definition tianzuo.Zhuiri.h:279
@ Zhuiri_error_code_socket
套接字错误 (socket error)
Definition tianzuo.Zhuiri.h:280
@ Zhuiri_error_code_user_reject
对方决绝 (user reject)
Definition tianzuo.Zhuiri.h:286
@ Zhuiri_error_code_handle
创建句柄失败 (handle error)
Definition tianzuo.Zhuiri.h:282
@ Zhuiri_error_code_time_out
操作超时 (time out)
Definition tianzuo.Zhuiri.h:285
@ Zhuiri_error_code_out_of_memory
内存溢出 (out of memory)
Definition tianzuo.Zhuiri.h:284
@ Zhuiri_error_code_thread_error
线程失败 (thread error)
Definition tianzuo.Zhuiri.h:281