00001 #ifndef __CHM_LLP_SERVER_H__ 00002 #define __CHM_LLP_SERVER_H__ 00003 00012 #include <CHM/CHMminimumInclude.h> 00013 // Predeclared Classes 00014 class CHMllpConnection; 00015 00016 00017 #ifndef __CHM_LISTENER_HANDLE_H__ 00018 #define __CHM_LISTENER_HANDLE_H__ 00019 typedef void* CHMlistenerHandle; 00020 #endif 00021 00022 00035 class CHMllpServer 00036 { 00037 public: 00039 CHMllpServer(); 00040 CHMllpServer(const CHMllpServer& Orig); 00041 CHMllpServer(CHMlistenerHandle Handle); 00042 00044 virtual ~CHMllpServer(); 00045 00047 CHMllpServer& operator=(const CHMllpServer& Orig); 00048 00050 CHMlistenerHandle GetHandle() const { return Handle; } 00051 00052 00057 CHMint32 Port() const; 00058 00059 00072 const char* Host() const; 00073 00074 00082 void SetHost(const char* Value); 00083 00084 00096 const char* HeaderBlock() const; 00097 00098 00106 void SetHeaderBlock(const char* Value); 00107 00108 00121 const char* TrailerBlock() const; 00122 00123 00131 void SetTrailerBlock(const char* Value); 00132 00133 00143 CHMboolean IsListening() const; 00144 00145 00163 CHMllpConnection Client(CHMint32 ClientIndex) const; 00164 00165 00172 CHMint32 CountOfClient() const; 00173 00174 00184 void StopMessageLoop(); 00185 00186 00205 static void RunMessageLoop(); 00206 00207 00226 void StartListen(CHMint32 Port); 00227 00228 00247 const char* MakeMessagePrintable(const char* InputString, const char* NewLine, CHMint32 MaximumLength); 00248 00249 00262 void StopListen(); 00263 00264 00277 void DisconnectAllClients(); 00278 00279 00287 virtual void OnErrorReceived(const char* ErrorMessage, CHMint32 Code)=0; 00288 00289 00297 virtual void OnClientConnected(CHMllpConnection& Client)=0; 00298 00299 00308 virtual void OnClientDisconnected(CHMllpConnection& Client)=0; 00309 00310 00323 virtual void OnClientErrorReceived(CHMllpConnection& Client, const char* ErrorMessage, CHMint32 ErrorCode)=0; 00324 00325 00337 virtual void OnMessageReceived(CHMllpConnection& Client, const char* Message)=0; 00338 00339 00352 virtual void OnDataIgnored(CHMllpConnection& Client, const char* Data)=0; 00353 00354 00355 private: 00356 CHMlistenerHandle Handle; 00357 static void setup(); 00358 }; 00359 00360 #endif // end of defensive include