netpeermanager.h

Go to the documentation of this file.
00001 /********************************************************************************/
00002 /*                                                                              */
00003 /*  Netrinjo-Engine - a library for game-development                            */
00004 /*  Copyright (C) 2005-2006 by Tobias Nadler                                    */
00005 /*                                                                              */
00006 /*  This library is free software; you can redistribute it and/or               */
00007 /*  modify it under the terms of the GNU Lesser General Public                  */
00008 /*  License as published by the Free Software Foundation; either                */
00009 /*  version 2.1 of the License, or (at your option) any later version.          */
00010 /*                                                                              */
00011 /*  This library is distributed in the hope that it will be useful,             */
00012 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of              */
00013 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU           */
00014 /*  Lesser General Public License for more details.                             */
00015 /*                                                                              */
00016 /*  You should have received a copy of the GNU Lesser General Public            */
00017 /*  License along with this library; if not, write to the Free Software         */
00018 /*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   */
00019 /*                                                                              */
00020 /********************************************************************************/
00021 
00022 #ifndef NETPEERMANAGER_H
00023 #define NETPEERMANAGER_H
00024 
00025 #include "netmanager.h"
00026 
00035 #define PEER_MAX_NAME       63
00036 
00040 #define PEER_MAX_REASON     255
00041 
00042 class NetPeerSocket;
00043 class TiXmlNode;
00044 
00062 class DECLSPEC NetPeerManager : public NetBasicManager
00063 {
00064 public:
00070     DECLSPEC NetPeerManager(const char *name, BasicObject *p, int maxpeers = 255 );
00090     DECLSPEC NetPeerManager(TiXmlElement *el, BasicObject *p );
00091     virtual DECLSPEC ~NetPeerManager();
00092     virtual const char *getClassName()  { return "NetPeerManager"; }
00093 
00103     virtual DECLSPEC bool init( unsigned int port = NETWORK_PORT, const char *permissionfn = 0 );
00104 
00111     DECLSPEC void setNetName( const char *name );
00115     DECLSPEC const char *getNetName() const {return chName;}
00116 
00122     DECLSPEC NetPeerSocket *getSocketByName( const char *name );
00123 
00127     DECLSPEC void requestPings();
00135     DECLSPEC Uint32 getPings( Uint32 *min, Uint32 *max );
00158     DECLSPEC bool loadPermissions( TiXmlNode *node );
00171     DECLSPEC bool loadPermissions( const char *fn );
00181     DECLSPEC bool hasPermission( const char *name, Uint32 host, char *reason = 0 );
00186     bool bAllowNewConnections;
00187 
00195     static NetPeerManager *getThe() { return (NetPeerManager*)NetBasicManager::getThe(); }
00196 protected:
00197     virtual DECLSPEC void onInit();
00198     virtual DECLSPEC NetSocket *createSocket( TCPsocket socket );
00199 
00200 private:
00201     struct HOST_INFO
00202     {
00203         char chName[PEER_MAX_NAME+1];
00204         Uint32 ip;
00205         bool bAllowed;
00206     };
00207     typedef list<HOST_INFO>::iterator PermissionIter;
00208     list<HOST_INFO> lPermissionInfos;
00209 
00210     int nMaxPeers;
00211     char chName[PEER_MAX_NAME+1];
00212 };
00213 
00214 #endif

Generated on Wed May 9 17:35:55 2007 for netrinjo by  doxygen 1.5.1