| 1 | /************************************************************************* |
| 2 | * libjson-rpc-cpp |
| 3 | ************************************************************************* |
| 4 | * @file abstractserverconnector.h |
| 5 | * @date 31.12.2012 |
| 6 | * @author Peter Spiess-Knafl <dev@spiessknafl.at> |
| 7 | * @license See attached LICENSE.txt |
| 8 | ************************************************************************/ |
| 9 | |
| 10 | #ifndef JSONRPC_CPP_SERVERCONNECTOR_H_ |
| 11 | #define JSONRPC_CPP_SERVERCONNECTOR_H_ |
| 12 | |
| 13 | #include "iclientconnectionhandler.h" |
| 14 | #include <string> |
| 15 | |
| 16 | namespace jsonrpc { |
| 17 | |
| 18 | class AbstractServerConnector { |
| 19 | public: |
| 20 | AbstractServerConnector(); |
| 21 | virtual ~AbstractServerConnector(); |
| 22 | |
| 23 | /** |
| 24 | * This method should signal the Connector to start waiting for requests, in |
| 25 | * any way that is appropriate for the derived connector class. |
| 26 | * If something went wrong, this method should return false, otherwise true. |
| 27 | */ |
| 28 | virtual bool StartListening() = 0; |
| 29 | /** |
| 30 | * This method should signal the Connector to stop waiting for requests, in |
| 31 | * any way that is appropriate for the derived connector class. |
| 32 | * If something went wrong, this method should return false, otherwise true. |
| 33 | */ |
| 34 | virtual bool StopListening() = 0; |
| 35 | |
| 36 | void ProcessRequest(const std::string &request, std::string &response); |
| 37 | |
| 38 | void SetHandler(IClientConnectionHandler *handler); |
| 39 | IClientConnectionHandler *GetHandler(); |
| 40 | |
| 41 | private: |
| 42 | IClientConnectionHandler *handler; |
| 43 | }; |
| 44 | |
| 45 | } /* namespace jsonrpc */ |
| 46 | #endif /* JSONRPC_CPP_ERVERCONNECTOR_H_ */ |
| 47 | |