提交 5536a3ea17b6a672b6d8e1feb422b821ea67376e

作者 LJH 李佳桓
1 个父辈 51a8df13

add

正在显示 1 个修改的文件 包含 71 行增加0 行删除
  1 +/*
  2 + * Copyright 2007 Stephen Liu
  3 + * For license terms, see the file COPYING along with this library.
  4 + */
  5 +
  6 +
  7 +#ifndef __sphandler_hpp__
  8 +#define __sphandler_hpp__
  9 +
  10 +class SP_Buffer;
  11 +class SP_Request;
  12 +class SP_Response;
  13 +class SP_Message;
  14 +
  15 +struct event;
  16 +struct timeval;
  17 +
  18 +class SP_Handler {
  19 +public:
  20 + virtual ~SP_Handler();
  21 +
  22 + // return -1 : terminate session, 0 : continue
  23 + virtual int start( SP_Request * request, SP_Response * response ) = 0;
  24 +
  25 + // return -1 : terminate session, 0 : continue
  26 + virtual int handle( SP_Request * request, SP_Response * response ) = 0;
  27 +
  28 + virtual void error( SP_Response * response ) = 0;
  29 +
  30 + virtual void timeout( SP_Response * response ) = 0;
  31 +
  32 + virtual void close() = 0;
  33 +};
  34 +
  35 +class SP_TimerHandler {
  36 +public:
  37 + virtual ~SP_TimerHandler();
  38 +
  39 + // return -1 : terminate timer, 0 : continue
  40 + virtual int handle( SP_Response * response, struct timeval * timeout ) = 0;
  41 +};
  42 +
  43 +/**
  44 + * @note Asynchronous Completion Token
  45 + */
  46 +class SP_CompletionHandler {
  47 +public:
  48 + virtual ~SP_CompletionHandler();
  49 +
  50 + virtual void completionMessage( SP_Message * msg ) = 0;
  51 +};
  52 +
  53 +class SP_DefaultCompletionHandler : public SP_CompletionHandler {
  54 +public:
  55 + SP_DefaultCompletionHandler();
  56 + ~SP_DefaultCompletionHandler();
  57 +
  58 + virtual void completionMessage( SP_Message * msg );
  59 +};
  60 +
  61 +class SP_HandlerFactory {
  62 +public:
  63 + virtual ~SP_HandlerFactory();
  64 +
  65 + virtual SP_Handler * create() const = 0;
  66 +
  67 + virtual SP_CompletionHandler * createCompletionHandler() const;
  68 +};
  69 +
  70 +#endif
  71 +
... ...
注册登录 后发表评论