00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef WEBSERVER_H
00023 #define WEBSERVER_H
00024
00025 #include "SDL/WebSrv.h"
00026 #include <list>
00027 #include "basiclog.h"
00028
00029 using namespace std;
00030
00031 class WebPage;
00032 class WebThread;
00033 class TiXmlElement;
00034 class TiXmlNode;
00035
00074 class DECLSPEC WebServer : public BasicLog
00075 {
00076 public:
00077 DECLSPEC WebServer(const char *name, BasicObject *p);
00094 DECLSPEC WebServer(TiXmlElement *el, BasicObject *p);
00095 DECLSPEC ~WebServer();
00096
00097 virtual const char *getClassName() { return "WebServer"; }
00107 virtual DECLSPEC bool init( Uint16 port = 80 );
00111 virtual DECLSPEC void destroy();
00112
00119 virtual DECLSPEC bool poll( Uint16 tWait = 0 );
00124 DECLSPEC void closeOutTimedThreads();
00125
00153 DECLSPEC void parseXMLNode( TiXmlNode *node );
00164 DECLSPEC int addPageDirectory( const char *dir, const char *basic_uri = "/", const char *fn_index = 0, bool subdirs = true );
00165
00166
00170 list<WebPage*>::iterator beginPage() { return lPages.begin(); }
00174 list<WebPage*>::iterator endPage() { return lPages.end(); }
00175
00179 static WebServer *the;
00187 DECLSPEC static WebServer *getThe();
00188 protected:
00189 virtual DECLSPEC void onInit();
00190 virtual DECLSPEC void onDestroy();
00192 TCPsocket socket;
00193
00195 list<WebPage*> lPages;
00197 list<WebThread*> lThreads;
00198
00199
00200
00201 private:
00202 void logIntro();
00203 WebSrv *webServer;
00204
00205 friend class WebPage;
00206 friend class WebThread;
00207 };
00208
00209 #endif