Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9625 in orxonox.OLD for branches/proxy/src/lib


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
Location:
branches/proxy/src/lib
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/coord/p_node.cc

    r9623 r9625  
    5454    parent->addChild(this);
    5555
    56   this->relCoordinate_handle = this->registerVarId( new SynchronizeableVector( &relCoordinate, &relCoordinate_write, "coordinate" ) );
    57   this->relDirection_handle = this->registerVarId( new SynchronizeableQuaternion( &relDirection, &relDirection_write, "direction" ) );
     56  this->relCoordinate_handle = this->registerVarId( new SynchronizeableVector( &relCoordinate, &relCoordinate_write, "coordinate", PERMISSION_SERVER ) );
     57  this->relDirection_handle = this->registerVarId( new SynchronizeableQuaternion( &relDirection, &relDirection_write, "direction", PERMISSION_SERVER ) );
    5858}
    5959
  • branches/proxy/src/lib/network/README.NETWORK

    r9597 r9625  
     1
     2
    13
    24
     
    810WORKING_STACK:
    911==============
    10  - it works to connecto to a master server which is connected to a proxy itself
    11 
     12 - removed compiler warnings in some modules
     13 - totaly rework of the permission system
     14 - introduced a new PERMISSION layer: PERMISSION_SERVER which gives the nearest server the authority to handle
    1215
    1316
  • branches/proxy/src/lib/network/monitor/network_monitor.cc

    r9589 r9625  
    1010
    1111### File Specific:
    12    main-programmer: Patrick Boenzli
     12   main-programmer: Patrick Boenzli (patrick@orxonox.ethz.ch)
    1313*/
    1414
     
    4949  this->networkStream = networkStream;
    5050  this->playerNumber = 0;
     51  this->connectionNumber = 0;
    5152  // create the localnode, init it and add it to the nodes list
    5253  this->localNode = new NetworkNode( this->networkStream->getPeerInfo());
     
    6970      peer->userId = -1;
    7071
    71       NetworkNode* node = new NetworkNode(peer);
    72       this->addNode( node);
    7372      this->addActiveProxyServer( this->localNode, peer);
    7473    }
     
    141140    return;
    142141
     142  PRINTF(0)("^^^^^^^^^^^^^^^^^^^^^^^^^^ adding node: %i with type: %s\n\n", pInfo->userId, pInfo->getNodeTypeString().c_str());
     143
    143144  if( pInfo->isClient())
    144     this->localNode->addClient(pInfo);
     145  {
     146    this->localNode->addClient(new NetworkNode(pInfo));
     147  }
    145148  else if( pInfo->isProxyServerActive())
    146149  {
    147     this->localNode->addActiveProxyServer(pInfo);
    148     // create a new node, since a proxy can connect clients again
    149     NetworkNode* node = new NetworkNode(pInfo);
    150     this->nodeList.push_back(node);
     150    this->localNode->addActiveProxyServer(new NetworkNode(pInfo));
     151  }
     152  else if( pInfo->isProxyServerActivePassive())
     153  {
     154    this->localNode->addPassiveProxyServer(new NetworkNode(pInfo));
    151155  }
    152156  else if( pInfo->isMasterServer())
    153157  {
    154     this->localNode->addMasterServer(pInfo);
    155   }
     158    this->localNode->addMasterServer(new NetworkNode(pInfo));
     159  }
     160  else
     161    assert(false);
    156162}
    157163
     
    168174
    169175  if( pInfo->isClient())
    170     node->addClient(pInfo);
     176    node->addClient(new NetworkNode(pInfo));
    171177  else if( pInfo->isProxyServerActive())
    172     node->addActiveProxyServer(pInfo);
     178    node->addActiveProxyServer(new NetworkNode(pInfo));
    173179  else if( pInfo->isMasterServer())
    174     node->addMasterServer(pInfo);
     180    node->addMasterServer(new NetworkNode(pInfo));
    175181}
    176182
     
    198204
    199205  if( pInfo->isClient())
    200     node->removeClient(pInfo);
     206    node->removeClient(pInfo->userId);
    201207  else if( pInfo->isProxyServerActive())
    202     node->removeActiveProxyServer(pInfo);
     208    node->removeActiveProxyServer(pInfo->userId);
    203209  else if( pInfo->isMasterServer())
    204     node->removeMasterServer(pInfo);
     210    node->removeMasterServer(pInfo->userId);
    205211}
    206212
     
    253259  for(; it != this->nodeList.end(); it++)
    254260  {
     261    PRINTF(0)("comparing %i to %i\n", (*it)->getPeerInfo()->userId, userId);
    255262    if( (*it)->getPeerInfo()->userId == userId)
    256263      return (*it);
     
    308315  for(; it != this->nodeList.end(); it++)
    309316  {
    310     (*it)->debug(0);
     317    (*it)->debug(1);
    311318  }
    312319
  • branches/proxy/src/lib/network/monitor/network_monitor.h

    r9601 r9625  
    4242
    4343    /** adds to @param node a network node @param pInfo a new client */
    44     inline void addClient(NetworkNode* node, PeerInfo* pInfo) { node->addClient(pInfo); }
     44    inline void addClient(NetworkNode* node, PeerInfo* pInfo) { node->addClient(new NetworkNode(pInfo)); }
    4545    /** adds to @param node a network node @param pInfo a new proxy server */
    46     inline void addActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addActiveProxyServer(pInfo); }
     46    inline void addActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addActiveProxyServer(new NetworkNode(pInfo)); }
    4747    /** adds to @param node a network node @param pInfo a new proxy server */
    48     inline void addPassiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addPassiveProxyServer(pInfo); }
     48    inline void addPassiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addPassiveProxyServer(new NetworkNode(pInfo)); }
    4949    /** adds to @param node a network node @param pInfo a new master server*/
    50     inline void addMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->addMasterServer(pInfo); }
     50    inline void addMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->addMasterServer(new NetworkNode(pInfo)); }
    5151
    5252    void removeNode(PeerInfo* pInfo);
    5353    void removeNode(NetworkNode* node, PeerInfo* pInfo);
    5454
    55     inline void removeClient(NetworkNode* node, PeerInfo* pInfo) { node->removeClient(pInfo); }
    56     inline void removeActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->removeActiveProxyServer(pInfo); }
    57     inline void removePassiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->removePassiveProxyServer(pInfo); }
    58     inline void removeMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->removeMasterServer(pInfo); }
     55    inline void removeClient(NetworkNode* node, int userId) { node->removeClient(userId); }
     56    inline void removeActiveProxyServer(NetworkNode* node, int userId) { node->removeActiveProxyServer(userId); }
     57    inline void removePassiveProxyServer(NetworkNode* node, int userId) { node->removePassiveProxyServer(userId); }
     58    inline void removeMasterServer(NetworkNode* node, int userId) { node->removeMasterServer(userId); }
    5959
    6060    PeerInfo* getFirstChoiceProxy() const;
     
    6464
    6565    /** @returns the active proxy server list of the localnode */
    66     inline std::list<PeerInfo*> getActiveProxyServer() const { return this->localNode->getActiveProxyServer(); }
     66    inline std::list<NetworkNode*> getActiveProxyServer() const { return this->localNode->getActiveProxyServer(); }
    6767
    6868    /* slots admin and info interface */
  • 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
  • branches/proxy/src/lib/network/monitor/network_node.h

    r9583 r9625  
    2222
    2323
    24     void addClient(PeerInfo* node);
    25     void addActiveProxyServer(PeerInfo* node);
    26     void addPassiveProxyServer(PeerInfo* node);
    27     void addMasterServer(PeerInfo* node);
     24    void addClient(NetworkNode* node);
     25    void addActiveProxyServer(NetworkNode* node);
     26    void addPassiveProxyServer(NetworkNode* node);
     27    void addMasterServer(NetworkNode* node);
    2828
    29     void removeClient(PeerInfo* node);
    30     void removeActiveProxyServer(PeerInfo* node);
    31     void removePassiveProxyServer(PeerInfo* node);
    32     void removeMasterServer(PeerInfo* node);
     29    void removeClient(NetworkNode* node);
     30    void removeActiveProxyServer(NetworkNode* node);
     31    void removePassiveProxyServer(NetworkNode* node);
     32    void removeMasterServer(NetworkNode* node);
     33
     34    void removeClient(int userId);
     35    void removeActiveProxyServer(int userId);
     36    void removePassiveProxyServer(int userId);
     37    void removeMasterServer(int userId);
     38
    3339
    3440    PeerInfo* getClient(int index) const;
     
    3844
    3945    /** @returns the master server list */
    40     inline std::list<PeerInfo*> getMasterServer() const { return this->masterServerList; }
     46    inline std::list<NetworkNode*> getMasterServer() const { return this->masterServerList; }
    4147    /** @returns the active proxy server list */
    42     inline std::list<PeerInfo*> getActiveProxyServer() const { return this->activeProxyServerList; }
     48    inline std::list<NetworkNode*> getActiveProxyServer() const { return this->activeProxyServerList; }
    4349    /** @returns the passive proxy server list */
    44     inline std::list<PeerInfo*> getPassiveProxyServer() const { return this->passiveProxyServerList; }
     50    inline std::list<NetworkNode*> getPassiveProxyServer() const { return this->passiveProxyServerList; }
    4551    /** @returns the client list */
    46     inline std::list<PeerInfo*> getClient() const { return this->clientList; }
     52    inline std::list<NetworkNode*> getClient() const { return this->clientList; }
    4753
    4854    PeerInfo* getPeerByUserId( int userId);
     
    6470
    6571    /* network nodes directly connected to this node */
    66     std::list<PeerInfo*>         clientList;                   //!< list of all clients in the network
    67     std::list<PeerInfo*>         activeProxyServerList;        //!< list of all proxy servers in the network
    68     std::list<PeerInfo*>         passiveProxyServerList;       //!< list of all proxy servers in the network
    69     std::list<PeerInfo*>         masterServerList;             //!< list of all master servers in the network (should be 1!! :D)
     72    std::list<NetworkNode*>         clientList;                   //!< list of all clients in the network
     73    std::list<NetworkNode*>         activeProxyServerList;        //!< list of all proxy servers in the network
     74    std::list<NetworkNode*>         passiveProxyServerList;       //!< list of all proxy servers in the network
     75    std::list<NetworkNode*>         masterServerList;             //!< list of all master servers in the network (should be 1!! :D)
    7076
    7177};
  • branches/proxy/src/lib/network/nettypes.h

    r9494 r9625  
    1010  PERMISSION_MASTER_SERVER = 1,
    1111  PERMISSION_PROXY_SERVER  = 2,
    12   PERMISSION_OWNER         = 4,
    13   PERMISSION_ALL           = 8
     12  PERMISSION_SERVER        = 4,
     13  PERMISSION_OWNER         = 8,
     14  PERMISSION_ALL           = 16
    1415};
    1516
  • branches/proxy/src/lib/network/network_game_manager.cc

    r9561 r9625  
    6868
    6969  this->gameState = 0;
    70   registerVar( new SynchronizeableInt( &gameState, &gameState, "gameState" ) );
     70  registerVar( new SynchronizeableInt( &gameState, &gameState, "gameState", PERMISSION_MASTER_SERVER ) );
    7171}
    7272
  • branches/proxy/src/lib/network/network_manager.cc

    r9604 r9625  
    142142
    143143  // then start the server
    144   this->networkStream->createServer( port, port + 1, port + 2);
     144//   this->networkStream->createServer( port, port + 1, port + 2);
    145145
    146146  // and to the other proxy servers also, this would be very nice if its works
  • branches/proxy/src/lib/network/network_stream.cc

    r9605 r9625  
    8181      // init the shared network data
    8282      SharedNetworkData::getInstance()->setHostID(NET_ID_MASTER_SERVER);
     83      this->pInfo->userId = NET_ID_MASTER_SERVER;
     84      this->pInfo->nodeType = NET_MASTER_SERVER;
     85
    8386      break;
    8487    case NET_PROXY_SERVER_ACTIVE:
    8588      // init the shared network data
    8689      SharedNetworkData::getInstance()->setHostID(NET_ID_PROXY_SERVER_01);
     90      this->pInfo->nodeType = NET_PROXY_SERVER_ACTIVE;
     91
    8792      break;
    8893    case NET_PROXY_SERVER_PASSIVE:
    8994      // init the shared network data
    9095      SharedNetworkData::getInstance()->setHostID(NET_ID_PROXY_SERVER_01);
     96      this->pInfo->nodeType = NET_PROXY_SERVER_PASSIVE;
     97
    9198      break;
    9299    case NET_CLIENT:
    93100      SharedNetworkData::getInstance()->setHostID(NET_ID_UNASSIGNED);
     101      this->pInfo->nodeType = NET_CLIENT;
    94102      break;
    95103  }
     
    526534    it++;
    527535  }
    528 
    529 
    530536}
    531537
     
    685691//               it->second.ip = it->second.socket->getRemoteAddress();
    686692
    687               // it->second.nodeType = it->second.handshake->getRemoteNodeType();
     693              it->second.nodeType = it->second.handshake->getRemoteNodeType();
    688694              // it->second.ip = it->second.socket->getRemoteAddress();
    689695              // add the new server to the nodes list (it can be a NET_MASTER_SERVER or NET_PROXY_SERVER)
  • branches/proxy/src/lib/network/player_stats.cc

    r9575 r9625  
    6565  this->oldNickName = "Player";
    6666
    67   userId_handle = registerVarId( new SynchronizeableInt( &assignedUserId, &assignedUserId, "userId" ) );
    68   teamId_handle = registerVarId( new SynchronizeableInt( &teamId, &teamId, "teamId" ) );
    69   preferedTeamId_handle = registerVarId( new SynchronizeableInt( &preferedTeamId, &preferedTeamId, "preferedUserId" ) );
    70   score_handle = registerVarId( new SynchronizeableInt( &score, &score, "score" ) );
    71   playableClassId_handle = registerVarId( new SynchronizeableInt( &playableClassId, &playableClassId, "playableClassId") );
    72   playableUniqueId_handle = registerVarId( new SynchronizeableInt( &playableUniqueId, &playableUniqueId, "playableUniqueId" ) );
    73   modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );
    74   nickName_handler = registerVarId( new SynchronizeableString( &nickName, &nickName, "nickName" ) );
     67  userId_handle = registerVarId( new SynchronizeableInt( &assignedUserId, &assignedUserId, "userId", PERMISSION_MASTER_SERVER ) );
     68  teamId_handle = registerVarId( new SynchronizeableInt( &teamId, &teamId, "teamId", PERMISSION_MASTER_SERVER ) );
     69  preferedTeamId_handle = registerVarId( new SynchronizeableInt( &preferedTeamId, &preferedTeamId, "preferedUserId", PERMISSION_MASTER_SERVER ) );
     70  score_handle = registerVarId( new SynchronizeableInt( &score, &score, "score", PERMISSION_MASTER_SERVER ) );
     71  playableClassId_handle = registerVarId( new SynchronizeableInt( &playableClassId, &playableClassId, "playableClassId", PERMISSION_MASTER_SERVER) );
     72  playableUniqueId_handle = registerVarId( new SynchronizeableInt( &playableUniqueId, &playableUniqueId, "playableUniqueId", PERMISSION_MASTER_SERVER ) );
     73  modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName", PERMISSION_MASTER_SERVER ) );
     74  nickName_handler = registerVarId( new SynchronizeableString( &nickName, &nickName, "nickName", PERMISSION_MASTER_SERVER ) );
    7575
    7676  MessageManager::getInstance()->registerMessageHandler( MSGID_CHANGENICKNAME, changeNickHandler, NULL );
  • branches/proxy/src/lib/network/proxy/proxy_control.cc

    r9603 r9625  
    3939
    4040
    41 // SHELL_COMMAND(forceReconnect, ProxyControl, forceReconnectionShell);
    42 SHELL_COMMAND(bla, ProxyControl, forceReconnectionShellThumb);
    43 
     41SHELL_COMMAND(forceReconnect, ProxyControl, forceReconnectionShell);
    4442
    4543/**
     
    250248void ProxyControl::forceReconnectionShell(int userId, int serverId)
    251249{
     250  PRINTF(0)("shell reconnectoin command: %i to %i\n", userId, serverId);
     251
    252252  this->forceReconnection(userId, serverId);
    253253}
     
    264264  if( serverInfo == NULL)
    265265  {
    266     PRINTF(0)("There is no node with userId %i registered in this network. Check the uid again\n");
    267     return;
    268   }
    269   else if( serverInfo->isMasterServer() || serverInfo->isProxyServerActive())
    270   {
    271     PRINTF(0)("You can't connecto to a client (userId %i)\n", serverId);
     266    PRINTF(0)("There is no server with userId %i registered in this network. Check the uid again\n", serverId);
     267    return;
     268  }
     269  else if( serverInfo->isClient())
     270  {
     271    PRINTF(0)("You can't connec to to a client (userId %i)\n", serverId);
    272272    return;
    273273  }
     
    306306  if( pInfo == NULL)
    307307  {
    308     PRINTF(0)("There is no node with userId %i registered in this network. Check the uid again\n");
     308    PRINTF(0)("There is no client with userId %i registered in this network. Check the uid again\n", userId);
    309309    return;
    310310  }
     
    316316  assert( Converter::intToByteArray( newAddress.host(), data + 2 * INTSIZE, INTSIZE ) == INTSIZE );
    317317
     318  PRINTF(0)("Sending reconnection command to: %i\n", userId);
    318319  MessageManager::getInstance()->sendMessage( MSGID_PROXY_COMMAND, data, 3*INTSIZE, RT_ALL_ME, NET_UNASSIGNED, MP_HIGHBANDWIDTH );
    319320}
  • branches/proxy/src/lib/network/proxy/proxy_control.h

    r9603 r9625  
    1818typedef enum proxyCommand {
    1919  PXY_RECONNECT              = 0,              //!< forces a reconnection of the node
     20
     21  PXY_WEAKUP,                                  //!< signal to weakup a sleeping proxy server (not impl. yet)
     22  PXY_SLEEP,                                   //!< signal to sleep and disconnect clients
    2023
    2124  PXY_NUMBER
  • branches/proxy/src/lib/network/synchronizeable.cc

    r9606 r9625  
    5555  /* make sure loadClassId is first synced var because this is read by networkStream */
    5656  assert( syncVarList.size() == 0 );
    57   mLeafClassId = this->registerVarId( new SynchronizeableInt( (int*)&this->getLeafClassID(), (int*)&this->getLeafClassID(), "leafClassId" ) );
    58 
    59   this->registerVar( new SynchronizeableInt( &this->owner, &this->owner, "owner" ) );
    60   this->registerVar( new SynchronizeableString( &this->objectName, &this->objectName, "objectName" ) );
     57  mLeafClassId = this->registerVarId( new SynchronizeableInt( (int*)&this->getLeafClassID(), (int*)&this->getLeafClassID(), "leafClassId", PERMISSION_MASTER_SERVER) );
     58
     59  this->registerVar( new SynchronizeableInt( &this->owner, &this->owner, "owner", PERMISSION_MASTER_SERVER ) );
     60  this->registerVar( new SynchronizeableString( &this->objectName, &this->objectName, "objectName", PERMISSION_MASTER_SERVER ) );
    6161}
    6262
     
    127127{
    128128  //make sure this user has his history
    129   if ( sentStates.size() <= userId )
     129  if ( (int)sentStates.size() <= userId )
    130130    sentStates.resize( userId+1 );
    131131
     
    207207  for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ )
    208208  {
     209
    209210    // DATA PERMISSIONS
    210211    // check if this synchronizeable has the permissions to write the data
    211212
     213#if 0
    212214    //  MASTER_SERVER |====> *
    213215    if( SharedNetworkData::getInstance()->isMasterServer() && (*it)->checkPermission( PERMISSION_MASTER_SERVER ))
     
    243245      hasPermission = true;
    244246
     247    else
     248      hasPermission = false;
     249#endif
     250
     251    ////////////////////////////////
     252    // Data SENDING Permissions
     253    ////////////////////////////////
     254
     255    // Permission   OWNER accept if:
     256    // I am the owner
     257    if(       (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == SharedNetworkData::getInstance()->getHostID())
     258      hasPermission = true;
     259    // reciever != owner && owner is local
     260    else if(  (*it)->checkPermission( PERMISSION_OWNER ) && userId != this->owner &&
     261                (SharedNetworkData::getInstance()->isUserLocal(this->owner) || this->owner == SharedNetworkData::getInstance()->getHostID()))
     262      hasPermission = true;
     263
     264
     265    // Permission   MASTER_SERVER accept if:
     266    // im MASTER_SERVER
     267    else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER ) && SharedNetworkData::getInstance()->isMasterServer())
     268      hasPermission = true;
     269    // im PROXY_SERVER && reciever == CLIENT
     270    else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER ) && SharedNetworkData::getInstance()->isProxyServerActive() &&
     271               SharedNetworkData::getInstance()->isUserClient( userId))
     272      hasPermission = true;
     273
     274
     275    // Pemission    SERVER accept if:
     276    // i am server && reciever == CLIENT
     277    else if( (*it)->checkPermission( PERMISSION_SERVER ) && !SharedNetworkData::getInstance()->isClient() &&
     278               SharedNetworkData::getInstance()->isUserClient( userId))
     279      hasPermission = true;
     280    // i am SERVER && reciever == SERVER && reciever != owner && ( owner is local || i am owner)
     281    else if( (*it)->checkPermission( PERMISSION_SERVER ) && !SharedNetworkData::getInstance()->isClient() &&
     282               userId != this->owner &&
     283               ( SharedNetworkData::getInstance()->isUserLocal( userId) || this->owner ==  SharedNetworkData::getInstance()->getHostID()))
     284      hasPermission = true;
     285
     286
     287    // Permission   ALL accept if:
     288    else if( (*it)->checkPermission( PERMISSION_ALL ))
     289      hasPermission = true;
     290
     291
     292    // or else refuse sending data
    245293    else
    246294      hasPermission = false;
     
    308356{
    309357  //make sure this user has his history
    310   if ( recvStates.size() <= userId )
     358  if ( (int)recvStates.size() <= userId )
    311359    recvStates.resize( userId+1 );
    312360
     
    367415
    368416
    369     //  *              <====|  MASTER_SERVER
    370     if(  this->networkStream->isUserMasterServer( userId ) && (*it)->checkPermission( PERMISSION_MASTER_SERVER ))
    371       hasPermission = true;
    372     else if( this->networkStream->isUserMasterServer( userId ) &&
    373              this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ))
    374       hasPermission = true;
    375 
    376     //  *              <====|  PROXY_SERVER
    377     else if( this->networkStream->isUserProxyServerActive( userId ) &&
    378              this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ))
    379       hasPermission = true;
    380     //  CLIENT         <====|  PROXY_SERVER
    381     else if( this->networkStream->isUserProxyServerActive( userId )  && SharedNetworkData::getInstance()->isClient()
    382              && (*it)->checkPermission( PERMISSION_MASTER_SERVER ))
    383       hasPermission = true;
    384     // MASTER_SERVER   <====|  PROXY_SERVER
    385     else if( this->networkStream->isUserProxyServerActive( userId )  && SharedNetworkData::getInstance()->isMasterServer() &&
    386              !this->networkStream->isUserLocal( userId ))
    387       hasPermission = true;
    388 
    389     //  *              <====|  OWNER
    390     else if( this->owner == userId && (*it)->checkPermission( PERMISSION_OWNER ))
    391       hasPermission = true;
    392 
    393     //  *              <====|  ALL
    394     else if( (*it)->checkPermission( PERMISSION_ALL ))
    395       hasPermission = true;
    396 
     417    ////////////////////////////////
     418    // Data RECIEVING Permissions
     419    ////////////////////////////////
     420
     421    // i should never ever receive a state update from a synchronizeable, that belongs to me! If it does somethings wrong with the send rules
     422//     assert(   !((*it)->checkPermission( PERMISSION_OWNER ) && this->owner == SharedNetworkData::getInstance()->getHostID()));
     423
     424
     425    // Permission   OWNER accept if:
     426    // sender == owner
     427    if(      (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == userId)
     428      hasPermission = true;
     429    // sender == MASTER_SERVER
     430    else if( (*it)->checkPermission( PERMISSION_OWNER ) && SharedNetworkData::getInstance()->isUserMasterServer( userId))
     431      hasPermission = true;
     432    // sender == PROXY_SERVER
     433    else if( (*it)->checkPermission( PERMISSION_OWNER ) && SharedNetworkData::getInstance()->isUserProxyServerActive( userId))
     434      hasPermission = true;
     435
     436    // Permission   MASTER_SERVER accept if:
     437    // sender == MASTER_SERVER
     438    else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER) && SharedNetworkData::getInstance()->isUserMasterServer( userId))
     439      hasPermission = true;
     440    // sender == PROXY_SERVER && im not MASTER_SERVER && im not PROXY_SERVER
     441    else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER) && SharedNetworkData::getInstance()->isClient() &&
     442               SharedNetworkData::getInstance()->isUserProxyServerActive( userId))
     443      hasPermission = true;
     444
     445    // Permission   SERVER accept if:
     446    // sender == SERVER
     447    else if( (*it)->checkPermission( PERMISSION_SERVER ) && !SharedNetworkData::getInstance()->isUserClient( userId) )
     448      hasPermission = true;
     449
     450    // Pemission    ALL accept if:
     451    else if(  (*it)->checkPermission( PERMISSION_ALL ))
     452      hasPermission = true;
     453
     454   // no rights to over-write local data
    397455    else
    398456      hasPermission = false;
     
    466524void Synchronizeable::cleanUpUser( int userId )
    467525{
    468   if ( recvStates.size() > userId )
     526  if ( (int)recvStates.size() > userId )
    469527  {
    470528    for ( std::list<StateHistoryEntry*>::iterator it = recvStates[userId].begin(); it != recvStates[userId].end(); it++ )
     
    481539  }
    482540
    483   if ( sentStates.size() > userId )
     541  if ( (int)sentStates.size() > userId )
    484542  {
    485543
     
    507565{
    508566   //make sure this user has his history
    509   if ( recvStates.size() <= userId )
     567  if ( (int)recvStates.size() <= userId )
    510568    recvStates.resize( userId+1 );
    511569
     
    597655{
    598656   //make sure this user has his history
    599   if ( sentStates.size() <= userId )
     657  if ( (int)sentStates.size() <= userId )
    600658    sentStates.resize( userId+1 );
    601659
  • branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_bool.h

    r9406 r9625  
    1212
    1313  public:
    14     SynchronizeableBool( bool * ptrIn, bool * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
     14    SynchronizeableBool( bool * ptrIn, bool * ptrOut, std::string name, int permission, int priority = 0 );
    1515    virtual ~SynchronizeableBool();
    1616
  • branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_float.h

    r9406 r9625  
    1313
    1414  public:
    15     SynchronizeableFloat( float * ptrIn, float * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
     15    SynchronizeableFloat( float * ptrIn, float * ptrOut, std::string name, int permission, int priority = 0 );
    1616    virtual ~SynchronizeableFloat();
    1717
  • branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_int.h

    r9406 r9625  
    1313
    1414  public:
    15     SynchronizeableInt( int * ptrIn, int * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
     15    SynchronizeableInt( int * ptrIn, int * ptrOut, std::string name, int permission, int priority = 0 );
    1616    virtual ~SynchronizeableInt();
    1717
  • branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_ip.h

    r9406 r9625  
    1515
    1616  public:
    17     SynchronizeableIP( IP *ptrIn, IP * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
     17    SynchronizeableIP( IP *ptrIn, IP * ptrOut, std::string name, int permission, int priority = 0 );
    1818    virtual ~SynchronizeableIP();
    1919
  • branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_quaternion.h

    r9406 r9625  
    1414
    1515  public:
    16     SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
     16    SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission, int priority = 0 );
    1717    virtual ~SynchronizeableQuaternion();
    1818
  • branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_string.h

    r9406 r9625  
    1414
    1515  public:
    16     SynchronizeableString( std::string * ptrIn, std::string * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
     16    SynchronizeableString( std::string * ptrIn, std::string * ptrOut, std::string name, int permission, int priority = 0 );
    1717    virtual ~SynchronizeableString();
    1818
  • branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_uint.h

    r9406 r9625  
    1313
    1414  public:
    15     SynchronizeableUInt( unsigned int * ptrIn, unsigned int * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
     15    SynchronizeableUInt( unsigned int * ptrIn, unsigned int * ptrOut, std::string name, int permission, int priority = 0 );
    1616    virtual ~SynchronizeableUInt();
    1717
  • branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_var.h

    r9494 r9625  
    1515
    1616  public:
    17     SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
     17    SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission, int priority = 0 );
    1818    virtual ~SynchronizeableVar();
    1919
  • branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_vector.h

    r9406 r9625  
    1414
    1515  public:
    16     SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
     16    SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission, int priority = 0 );
    1717    virtual ~SynchronizeableVector();
    1818
Note: See TracChangeset for help on using the changeset viewer.