Google
Web alhem.net
Main Page | Alphabetical List | Class List | File List | Class Members | File Members

MyHandler.h

Go to the documentation of this file.
00001 
00006 /*
00007 Copyright (C) 2004  Anders Hedstrom
00008 
00009 This program is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2
00012 of the License, or (at your option) any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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

Generated on Tue Oct 3 23:47:05 2006 for The Minder by doxygen 1.3.6