Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 30, 2006, 11:19:24 PM (18 years ago)
Author:
patrick
Message:

yet another weekend commit, quite much work done:

  • introduced a new PERMISSION layer: PERMISSION_SERVER: the nearest server hast authority
  • tightening up permissions: brand new implementation to prevent sending unused variables in the network (less smog in the net:D_
  • removed some compiler warnings from some central modules
  • networkmonitor interface changed to work with networknodes mainly
  • better debug output for the network monitor
  • networnode inteface standardisation
  • force reconnection commands integration
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/monitor/network_node.cc

    r9583 r9625  
    3939 * adds a client
    4040 */
    41 void NetworkNode::addClient(PeerInfo* node)
     41void NetworkNode::addClient(NetworkNode* node)
    4242{
    4343  this->clientList.push_back(node);
     
    4949 * adds a proxy server
    5050 */
    51 void NetworkNode::addActiveProxyServer(PeerInfo* node)
     51void NetworkNode::addActiveProxyServer(NetworkNode* node)
    5252{
    5353  this->activeProxyServerList.push_back(node);
     
    5858 * adds a proxy server
    5959 */
    60 void NetworkNode::addPassiveProxyServer(PeerInfo* node)
     60void NetworkNode::addPassiveProxyServer(NetworkNode* node)
    6161{
    6262  this->passiveProxyServerList.push_back(node);
     
    6666 * adds a master server
    6767 */
    68 void NetworkNode::addMasterServer(PeerInfo* node)
     68void NetworkNode::addMasterServer(NetworkNode* node)
    6969{
    7070  this->masterServerList.push_back(node);
     
    7575 * removes a client
    7676 */
    77 void NetworkNode::removeClient(PeerInfo* node)
    78 {
    79   std::list<PeerInfo*>::iterator it = this->clientList.begin();
     77void NetworkNode::removeClient(NetworkNode* node)
     78{
     79  std::list<NetworkNode*>::iterator it = this->clientList.begin();
    8080  for(; it != this->clientList.end(); it++)
    8181  {
     
    9494 * removes a proxy server
    9595 */
    96 void NetworkNode::removeActiveProxyServer(PeerInfo* node)
    97 {
    98   std::list<PeerInfo*>::iterator it = this->activeProxyServerList.begin();
     96void NetworkNode::removeActiveProxyServer(NetworkNode* node)
     97{
     98  std::list<NetworkNode*>::iterator it = this->activeProxyServerList.begin();
    9999  for(; it != this->activeProxyServerList.end(); it++)
    100100  {
     
    113113 * removes a proxy server
    114114 */
    115 void NetworkNode::removePassiveProxyServer(PeerInfo* node)
    116 {
    117   std::list<PeerInfo*>::iterator it = this->passiveProxyServerList.begin();
     115void NetworkNode::removePassiveProxyServer(NetworkNode* node)
     116{
     117  std::list<NetworkNode*>::iterator it = this->passiveProxyServerList.begin();
    118118  for(; it != this->passiveProxyServerList.end(); it++)
    119119  {
     
    131131 * removes a master server
    132132 */
    133 void NetworkNode::removeMasterServer(PeerInfo* node)
    134 {
    135   std::list<PeerInfo*>::iterator it = this->masterServerList.begin();
     133void NetworkNode::removeMasterServer(NetworkNode* node)
     134{
     135  std::list<NetworkNode*>::iterator it = this->masterServerList.begin();
    136136  for(; it != this->masterServerList.end(); it++)
    137137  {
     
    146146  PRINTF(2)("Could not remove client from the list, very strange...");
    147147}
     148
     149
     150
     151
     152/**
     153 * removes a client
     154 */
     155void NetworkNode::removeClient(int userId)
     156{
     157  std::list<NetworkNode*>::iterator it = this->clientList.begin();
     158  for(; it != this->clientList.end(); it++)
     159  {
     160    if( (*it)->getPeerInfo()->userId == userId)
     161    {
     162      this->clientList.erase(it);
     163      this->playerNumber--;
     164      return;
     165    }
     166  }
     167
     168  PRINTF(2)("Could not remove client from the list, very strange...");
     169}
     170
     171/**
     172 * removes a proxy server
     173 */
     174void NetworkNode::removeActiveProxyServer(int userId)
     175{
     176  std::list<NetworkNode*>::iterator it = this->activeProxyServerList.begin();
     177  for(; it != this->activeProxyServerList.end(); it++)
     178  {
     179    if( (*it)->getPeerInfo()->userId == userId)
     180    {
     181      this->activeProxyServerList.erase(it);
     182      this->playerNumber--;
     183      return;
     184    }
     185  }
     186
     187  PRINTF(2)("Could not remove proxy server from the list, very strange...");
     188}
     189
     190/**
     191 * removes a proxy server
     192 */
     193void NetworkNode::removePassiveProxyServer(int userId)
     194{
     195  std::list<NetworkNode*>::iterator it = this->passiveProxyServerList.begin();
     196  for(; it != this->passiveProxyServerList.end(); it++)
     197  {
     198    if( (*it)->getPeerInfo()->userId == userId)
     199    {
     200      this->passiveProxyServerList.erase(it);
     201      return;
     202    }
     203  }
     204
     205  PRINTF(2)("Could not remove proxy server from the list, very strange...");
     206}
     207
     208/**
     209 * removes a master server
     210 */
     211void NetworkNode::removeMasterServer(int userId)
     212{
     213  std::list<NetworkNode*>::iterator it = this->masterServerList.begin();
     214  for(; it != this->masterServerList.end(); it++)
     215  {
     216    if( (*it)->getPeerInfo()->userId == userId)
     217    {
     218      this->masterServerList.erase(it);
     219      this->playerNumber--;
     220      return;
     221    }
     222  }
     223
     224  PRINTF(2)("Could not remove client from the list, very strange...");
     225}
     226
     227
    148228
    149229
     
    157237{
    158238  // look through the master server lists
    159   std::list<PeerInfo*>::const_iterator it = this->masterServerList.begin();
     239  std::list<NetworkNode*>::const_iterator it = this->masterServerList.begin();
    160240  for( ;it != this->masterServerList.end(); it++)
    161241  {
    162     if( (*it)->userId == userId)
    163       return (*it);
     242    if( (*it)->getPeerInfo()->userId == userId)
     243      return (*it)->getPeerInfo();
    164244  }
    165245
     
    168248  for( ; it != this->activeProxyServerList.end(); it++)
    169249  {
    170     if( (*it)->userId == userId)
    171       return (*it);
     250    if( (*it)->getPeerInfo()->userId == userId)
     251      return (*it)->getPeerInfo();
    172252  }
    173253
     
    176256  for( ; it != this->passiveProxyServerList.end(); it++)
    177257  {
    178     if( (*it)->userId == userId)
    179       return (*it);
     258    if( (*it)->getPeerInfo()->userId == userId)
     259      return (*it)->getPeerInfo();
    180260  }
    181261
     
    184264  for( ; it != this->clientList.end(); it++)
    185265  {
    186     if( (*it)->userId == userId)
    187       return (*it);
     266    if( (*it)->getPeerInfo()->userId == userId)
     267      return (*it)->getPeerInfo();
    188268  }
    189269
     
    201281    return NULL;
    202282
    203   std::list<PeerInfo*>::const_iterator it = this->clientList.begin();
     283  std::list<NetworkNode*>::const_iterator it = this->clientList.begin();
    204284  for(int i = 0; it != this->clientList.end(); it++, i++)
    205285  {
    206286  if( i == index)
    207     return (*it);
     287    return (*it)->getPeerInfo();
    208288  }
    209289
     
    221301    return NULL;
    222302
    223   std::list<PeerInfo*>::const_iterator it = this->activeProxyServerList.begin();
     303  std::list<NetworkNode*>::const_iterator it = this->activeProxyServerList.begin();
    224304  for(int i = 0; it != this->activeProxyServerList.end(); it++, i++)
    225305  {
    226306    if( i == index)
    227       return (*it);
     307      return (*it)->getPeerInfo();
    228308  }
    229309
     
    241321    return NULL;
    242322
    243   std::list<PeerInfo*>::const_iterator it = this->passiveProxyServerList.begin();
     323  std::list<NetworkNode*>::const_iterator it = this->passiveProxyServerList.begin();
    244324  for(int i = 0; it != this->passiveProxyServerList.end(); it++, i++)
    245325  {
    246326    if( i == index)
    247       return (*it);
     327      return (*it)->getPeerInfo();
    248328  }
    249329
     
    261341    return NULL;
    262342
    263   std::list<PeerInfo*>::const_iterator it = this->masterServerList.begin();
     343  std::list<NetworkNode*>::const_iterator it = this->masterServerList.begin();
    264344  for(int i = 0; it != this->masterServerList.end(); it++, i++)
    265345  {
    266346    if( i == index)
    267       return (*it);
     347      return (*it)->getPeerInfo();
    268348  }
    269349
     
    278358void NetworkNode::debug(int depth) const
    279359{
    280   PRINT(0)(" = %s\n", this->peerInfo->getNodeTypeString().c_str());
    281 
    282   PRINT(0)("    master servers: %i\n", this->masterServerList.size());
    283   std::list<PeerInfo*>::const_iterator it = this->masterServerList.begin();
    284   for(; it != this->masterServerList.end(); it++)
    285   {
    286     IP* ip = &(*it)->ip;
    287     PRINT(0)("     - ms, id: %i (%s)\n", (*it)->userId, ip->ipString().c_str());
    288   }
    289 
    290   PRINT(0)("    proxy servers active: %i\n", this->activeProxyServerList.size());
    291   it = this->activeProxyServerList.begin();
    292   for(; it != this->activeProxyServerList.end(); it++)
    293   {
    294     IP* ip = &(*it)->ip;
    295     PRINT(0)("     - ps-a, id: %i (%s)\n", (*it)->userId, ip->ipString().c_str());
    296   }
    297 
    298   PRINT(0)("    proxy servers passive: %i\n", this->passiveProxyServerList.size());
    299   it = this->passiveProxyServerList.begin();
    300   for(; it != this->passiveProxyServerList.end(); it++)
    301   {
    302     IP* ip = &(*it)->ip;
    303     PRINT(0)("     - ps-p, id: %i (%s)\n", (*it)->userId, ip->ipString().c_str());
    304   }
    305 
    306   PRINT(0)("    clients: %i\n", this->clientList.size());
    307   it = this->clientList.begin();
    308   for(; it != this->clientList.end(); it++)
    309   {
    310     IP* ip = &(*it)->ip;
    311     PRINT(0)("     - client, id: %i (%s)\n", (*it)->userId, ip->ipString().c_str());
    312   }
    313 }
    314 
     360  char indent[depth +1];
     361  for( int i = 0; i < depth; i++) {     indent[i] = ' ';  }
     362  indent[depth] = '\0';
     363
     364  PRINT(0)("%s + %s, with ip: %s\n", indent,  this->peerInfo->getNodeTypeString().c_str(), this->peerInfo->ip.ipString().c_str());
     365  std::list<NetworkNode*>::const_iterator it;
     366  if( !this->masterServerList.empty())
     367  {
     368//     PRINT(0)("%s + master servers: %i\n", indent, this->masterServerList.size());
     369    it = this->masterServerList.begin();
     370
     371    for(; it != this->masterServerList.end(); it++)
     372    {
     373//       IP* ip = &(*it)->getPeerInfo()->ip;
     374//       PRINT(0)("%s     - ms, id: %i (%s)\n", indent, (*it)->getPeerInfo()->userId, ip->ipString().c_str());
     375      (*it)->debug(depth+1);
     376    }
     377  }
     378
     379  if( !this->activeProxyServerList.empty())
     380  {
     381//     PRINT(0)("%s + proxy servers active: %i\n", indent, this->activeProxyServerList.size());
     382    it = this->activeProxyServerList.begin();
     383
     384    for(; it != this->activeProxyServerList.end(); it++)
     385    {
     386//       IP* ip = &(*it)->getPeerInfo()->ip;
     387//       PRINT(0)("%s     - ps-a, id: %i (%s)\n", indent, (*it)->getPeerInfo()->userId, ip->ipString().c_str());
     388      (*it)->debug(depth+1);
     389    }
     390  }
     391
     392
     393  if( !this->passiveProxyServerList.empty())
     394  {
     395//     PRINT(0)("%s proxy servers passive: %i\n", indent, this->passiveProxyServerList.size());
     396    it = this->passiveProxyServerList.begin();
     397
     398    for(; it != this->passiveProxyServerList.end(); it++)
     399    {
     400//       IP* ip = &(*it)->getPeerInfo()->ip;
     401//       PRINT(0)("%s     - ps-p, id: %i (%s)\n", indent, (*it)->getPeerInfo()->userId, ip->ipString().c_str());
     402      (*it)->debug(depth+1);
     403    }
     404  }
     405
     406  if( !this->clientList.empty())
     407  {
     408//     PRINT(0)("%s clients: %i\n", indent, this->clientList.size());
     409    it = this->clientList.begin();
     410
     411    for(; it != this->clientList.end(); it++)
     412    {
     413//       IP* ip = &(*it)->getPeerInfo()->ip;
     414//       PRINT(0)("%s     - client, id: %i (%s)\n", indent, (*it)->getPeerInfo()->userId, ip->ipString().c_str());
     415      (*it)->debug(depth+1);
     416    }
     417  }
     418}
     419
Note: See TracChangeset for help on using the changeset viewer.