00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef SERVER_H
00025 #define SERVER_H
00026
00027 #include "ResponseMessage.h"
00028 #include "QueryMessage.h"
00029 #include "Message.h"
00030 #include "Socket.h"
00031 #include "AccessList.h"
00032
00033 #include <prthread.h>
00034 #include <prlog.h>
00035
00036 namespace net
00037 {
00043 class ServerInterface
00044 {
00045
00046 protected:
00047
00051 Socket *mSock;
00055 PRThread *mThread;
00059 AccessList *mAccessList;
00060
00064 string mIPAuthFile;
00065 public:
00066
00070 ServerInterface();
00071
00075 virtual ~ServerInterface();
00076
00077
00078 PRThread* createThread(PRThreadType type,
00079 void (*start)(void *arg),
00080 void *arg,
00081 PRThreadPriority priority,
00082 PRThreadScope scope,
00083 PRThreadState state,
00084 PRUint32 stackSize, PRInt32 index);
00085
00091 virtual ResponseMessage ProcessQuery(QueryMessage) = 0;
00092
00096 int Run();
00097
00101 void Stop();
00102
00107 void setSock(Socket *);
00108
00114 int setIPAuth(string);
00115
00120 AccessList *getAccessList();
00121
00122 friend void PR_CALLBACK net::thread(void *);
00123
00124
00125
00126 static const int kCLIENT_QUIT_OK;
00127 static const int kWAITING_FOR_DATA;
00128 static const int kDESCRIPTOR_OK;
00129 static const int kCLIENT_IP_OK;
00130
00131
00132 static const int kCOMMAND_NOT_IMPLEMENTED;
00133 static const int kDESCRIPTOR_FAILED;
00134 static const int kINVALID_CLIENT_IP;
00135 static const int kINTERNAL_ERROR;
00136 static const int kBUSY;
00137 };
00138 }
00139
00140 #endif