#ifndef __ProxyMainLoop_h_ #define __ProxyMainLoop_h_ #include "../shared/ThreadClass.h" #include "../shared/Messages.h" #include "../shared/InputFramework.h" #include "../shared/DeadManTimer.h" #include "HttpThread.h" class ProxyMainLoop : private ThreadClass, public HttpListener, private HttpResponsePrep { private: enum { // From server to us. mtServerInput, // From the client to us. mtHttpRequest, // Read timeout. The client is ready to receive data from the server. // But we don't have any data yet. If we get data soon, we'll send it // to the client. If we don't get anything for a while, we send an empty // response to the client. That's like a ping, so the client knows that // the connection is still alive, even if there is no interesting data. mtReadTimeout, // Standard request from destructor. mtQuit }; RequestQueue _incoming; InputListener _serverListener; DeadManTimer _deadManTimer; void clientConnect(HttpRequest *httpRequest); void clientRead(HttpRequest *httpRequest); void clientWrite(HttpRequest *httpRequest); void clientDisconnect(HttpRequest *httpRequest); void clientInfo(HttpRequest *httpRequest); void prepairHttpResponse(HttpRequest *request, ScgiToServer &response); protected: void threadFunction(); public: ProxyMainLoop(); ~ProxyMainLoop(); virtual void onHttpRequest(HttpRequest *httpRequest); }; #endif