sphandler.hpp
1.5 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
61
62
63
64
65
66
67
68
69
70
71
/*
* Copyright 2007 Stephen Liu
* For license terms, see the file COPYING along with this library.
*/
#ifndef __sphandler_hpp__
#define __sphandler_hpp__
class SP_Buffer;
class SP_Request;
class SP_Response;
class SP_Message;
struct event;
struct timeval;
class SP_Handler {
public:
virtual ~SP_Handler();
// return -1 : terminate session, 0 : continue
virtual int start( SP_Request * request, SP_Response * response ) = 0;
// return -1 : terminate session, 0 : continue
virtual int handle( SP_Request * request, SP_Response * response ) = 0;
virtual void error( SP_Response * response ) = 0;
virtual void timeout( SP_Response * response ) = 0;
virtual void close() = 0;
};
class SP_TimerHandler {
public:
virtual ~SP_TimerHandler();
// return -1 : terminate timer, 0 : continue
virtual int handle( SP_Response * response, struct timeval * timeout ) = 0;
};
/**
* @note Asynchronous Completion Token
*/
class SP_CompletionHandler {
public:
virtual ~SP_CompletionHandler();
virtual void completionMessage( SP_Message * msg ) = 0;
};
class SP_DefaultCompletionHandler : public SP_CompletionHandler {
public:
SP_DefaultCompletionHandler();
~SP_DefaultCompletionHandler();
virtual void completionMessage( SP_Message * msg );
};
class SP_HandlerFactory {
public:
virtual ~SP_HandlerFactory();
virtual SP_Handler * create() const = 0;
virtual SP_CompletionHandler * createCompletionHandler() const;
};
#endif