/** ** File ......... MyHandler.h ** Published .... 2004-04-18 ** Author ....... grymse@alhem.net **/ /* Copyright (C) 2004 Anders Hedstrom This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _MINDER_MYHANDLER_H #define _MINDER_MYHANDLER_H #include #include struct HOST { HOST(const std::string& str,ipaddr_t l,port_t i) : id(str) , ip(l) , port(i) , extra_information(0) , behind_firewall(false) , connectable(false) {} unsigned long host_id; std::string id; ipaddr_t ip; port_t port; long extra_information; time_t t; bool behind_firewall; bool sent; bool connectable; }; typedef std::vector host_v; typedef std::map app_m; class MyHandler : public SocketHandler { public: MyHandler(); ~MyHandler(); void CheckTimeout(); HOST * reg_host(const std::string& map,const std::string&,ipaddr_t,port_t,ipaddr_t,unsigned long&,long); void unreg_host(const std::string& map,const std::string&,ipaddr_t,port_t,ipaddr_t); HOST * GetRandomHOST(const std::string& map,bool must_be_connectable = false); void reset_sent(const std::string& map); void ViewHosts(); private: app_m m_app; }; #endif // _MINDER_MYHANDLER_H