-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpacket_processor.h
62 lines (47 loc) · 1.42 KB
/
packet_processor.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
/*
* packet_processor.h
*
* Created on: 2011-12-1
* Author: gxl2007@hotmail.com
*/
#ifndef PACKET_PROCESSOR_H_
#define PACKET_PROCESSOR_H_
namespace xlnet
{
class tcp_connection ;
struct packet_info ;
class packet_processor
{
public:
virtual ~packet_processor() { } ;
/*
* @brief get packet info , implemented by concrete class
* @param [in] buffer pointer
* @param [in] buffer size
* @param [out] packet info
* @return 0 on success , -1 on failure
*/
virtual int get_info(const char* data,int size,packet_info* pi) = 0 ;
/*
* @brief process packet callback , implemented by concrete class
* @param [in] connection pointer
* @param [in] packet info
* @return 0 on success , -1 on failure
*/
virtual int process(tcp_connection* conn,const packet_info* pi) = 0 ;
/*
* @brief connect event callllback , implemented by concrete class
* @param [in] connection pointer
* @param [in] reason
*/
virtual void on_connected(tcp_connection* conn) = 0 ;
/*
* @brief disconnect event callllback , implemented by concrete class
* @param [in] connection pointer
* @param [in] reason
*/
virtual void on_disconnect(tcp_connection* conn ) = 0 ;
virtual void on_error(tcp_connection* conn,int error_type) = 0 ;
};
}
#endif /* PACKET_PROCESSOR_H_ */