// Copyright 2019, Chen Shuaihao. // //Author: Chen Shuaihao // // #ifndef _HTTP_SERVER_H_ #define _HTTP_SERVER_H_ #include #include #include #include "EventLoop.h" #include "TcpServer.h" #include "TcpConnection.h" #include "HttpSession.h" #include "ThreadPool.h" #include "Timer.h" class HttpServer { public: //tcpè¿æ¥çæºè½æéç±»å typedef std::shared_ptr spTcpConnection; //宿¶å¨çæºè½æéç±»å typedef std::shared_ptr spTimer; HttpServer(EventLoop *loop, const int port, const int iothreadnum, const int workerthreadnum); ~HttpServer(); //å¯å¨Httpæå¡å¨ void Start(); private: //æ°è¿æ¥åè°å½æ° void HandleNewConnection(const spTcpConnection& sptcpconn); //æ°æ®æ¥æ¶åè°å½æ° void HandleMessage(const spTcpConnection &sptcpconn, std::string &msg); //æ°æ®åé宿åè°å½æ° void HandleSendComplete(const spTcpConnection& sptcpconn); //è¿æ¥å ³éåè°å½æ° void HandleClose(const spTcpConnection& sptcpconn); //è¿æ¥å¼å¸¸åè°å½æ° void HandleError(const spTcpConnection& sptcpconn); //bugfix:声æé¡ºåºè°æ´ï¼mapãmutexæ¾å°æåææ //管çHttpä¼è¯ std::map > httpsessionnlist_; //管ç宿¶å¨,ç»´æ¤æ´»è·è¿æ¥ std::map timerlist_; //ä¿æ¤ä»¥ä¸ä¸¤ä¸ªmapçäºæ¥é std::mutex mutex_; //tcpæå¡å¨ TcpServer tcpserver_; //å·¥ä½çº¿ç¨æ± ThreadPool threadpool_; }; #endif