Logo
~Sockets~
~Examples~
~Contact~


MinionSocket.h

Go to the documentation of this file.
00001 /*
00002  **     File ......... MinionSocket.h
00003  **     Published ....  2004-04-17
00004  **     Author ....... grymse@alhem.net
00005 **/
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 _SOCKETS_MinionSocket_H
00024 #define _SOCKETS_MinionSocket_H
00025 #include "sockets-config.h"
00026 #ifdef HAVE_OPENSSL
00027 
00028 //#include <string>
00029 //#include <vector>
00030 #include "CTcpSocket.h"
00031 #include "Parse.h"
00032 //#include "Utility.h"
00033 #include "ISocketHandler.h"
00034 
00035 #ifdef SOCKETS_NAMESPACE
00036 namespace SOCKETS_NAMESPACE {
00037 #endif
00038 
00039 
00040 class ICrypt;
00041 
00042 
00043 
00044         typedef std::vector<unsigned long> ulong_v;
00045 
00048 class MinionSocket : public CTcpSocket
00049 {
00050 public:
00051         MinionSocket(ISocketHandler& );
00052         MinionSocket(ISocketHandler&,const std::string&,ipaddr_t,port_t);
00053         ~MinionSocket();
00054 
00055 //      ICrypt *AllocateCrypt();
00056 
00057         void SendConnectList();
00058 
00059         void SetMyIpPort(ipaddr_t l,port_t s) { my_ip = l; my_port = s; }
00060 
00061         void SendHello(const std::string&);
00062         ipaddr_t GetIP() { return m_ip; }
00063         port_t GetPort() { return m_port; }
00064 
00065         void OnAccept();
00066 
00067         const std::string& GetRemoteId() { return m_remote_id; }
00068         virtual bool OnVerifiedLine(const std::string& cmd,Parse& pa);
00069         void StopMessage(bool x = true) { m_bStopMessage = x; }
00070 
00071         long GetMessageCount() { return m_messagecount; }
00072         long GetSeenCount() { return m_seencount; }
00073         virtual void Notify(const std::string& ) {}
00074 
00075         void SetRemoteHostId(long x) { m_remote_host_id = x; }
00076         long GetRemoteHostId() { return m_remote_host_id; }
00077 
00078         virtual int GetMaxConnections() = 0;
00079         virtual unsigned char *GetKey_m2minion() = 0;
00080 
00081         ipaddr_t GetMyIP() { return my_ip; }
00082         port_t GetMyPort() { return my_port; }
00083         void SetRemoteId(const std::string& x) { m_remote_id = x; }
00084         void SetIP(ipaddr_t x) { m_ip = x; }
00085         void SetPort(port_t x) { m_port = x; }
00086         void SetIDVerified(bool x = true) { m_bIDVerified = x; }
00087 
00088 protected:
00089         void OnDelete();
00090         void OnConnect();
00091         void OnLine(const std::string& line);
00092 
00093 private:
00094         MinionSocket& operator=(const MinionSocket& ) { return *this; }
00095         std::string     m_remote_id;
00096         ipaddr_t        m_ip;
00097         port_t          m_port;
00098         ipaddr_t        my_ip;
00099         port_t          my_port;
00100         bool            m_bIDVerified;
00101         std::list<std::string>  m_clist;
00102         bool            m_bStopMessage;
00103         long            m_messagecount;
00104         long            m_seencount;
00105         long            m_remote_host_id;
00106 };
00107 
00108 
00109 #ifdef SOCKETS_NAMESPACE
00110 }
00111 #endif
00112 
00113 #endif // HAVE_OPENSSL
00114 #endif // _SOCKETS_MinionSocket_H
Page, code, and content Copyright (C) 2007 by Anders Hedström
Generated for C++ Sockets by  doxygen 1.4.4