00001 #ifndef WS_SERVER_H
00002 #define WS_SERVER_H
00003
00004 #include <string>
00005 #include <map>
00006
00007 #ifdef WIN32
00008 #include <windows.h>
00009 #include <winsock2.h>
00010 #else
00011 #include <sys/types.h>
00012 #include <sys/socket.h>
00013 #include <netinet/in.h>
00014 #include <arpa/inet.h>
00015 #endif
00016
00017 using namespace std;
00018
00019 class wsRequest;
00020
00021 class wsServer
00022 {
00023 public:
00024
00025 typedef void (*handler)();
00026
00027 wsServer(unsigned int port);
00028
00029 wsRequest* getRequest();
00030
00031 void addHandler(const string& url, handler h)
00032 {
00033 myHandlers[url] = h;
00034 }
00035
00036 private:
00037
00038 unsigned int myPort;
00039 int mySocket;
00040 sockaddr_in myAddr;
00041 map<string,handler> myHandlers;
00042 };
00043
00044 #endif
00045