00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _MINDER_MYHANDLER_H
00024 #define _MINDER_MYHANDLER_H
00025
00026 #include <SocketHandler.h>
00027 #include <Utility.h>
00028
00029
00030 struct HOST
00031 {
00032 HOST(const std::string& str,ipaddr_t l,port_t i)
00033 : id(str)
00034 , ip(l)
00035 , port(i)
00036 , extra_information(0)
00037 , behind_firewall(false)
00038 , connectable(false) {}
00039 unsigned long host_id;
00040 std::string id;
00041 ipaddr_t ip;
00042 port_t port;
00043 long extra_information;
00044 time_t t;
00045 bool behind_firewall;
00046 bool sent;
00047 bool connectable;
00048 };
00049 typedef std::vector<struct HOST *> host_v;
00050 typedef std::map<std::string,host_v> app_m;
00051
00052
00053 class MyHandler : public SocketHandler
00054 {
00055 public:
00056 MyHandler();
00057 ~MyHandler();
00058
00059 void CheckTimeout();
00060
00061 HOST * reg_host(const std::string& map,const std::string&,ipaddr_t,port_t,ipaddr_t,unsigned long&,long);
00062 void unreg_host(const std::string& map,const std::string&,ipaddr_t,port_t,ipaddr_t);
00063 HOST * GetRandomHOST(const std::string& map,bool must_be_connectable = false);
00064 void reset_sent(const std::string& map);
00065
00066 void ViewHosts();
00067
00068 private:
00069 app_m m_app;
00070
00071 };
00072
00073
00074
00075
00076 #endif // _MINDER_MYHANDLER_H