Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 23, 2006, 10:07:23 PM (18 years ago)
Author:
patrick
Message:

committing my weekends work: 2100 lines :D

  • proxy server now accepts and synchronizes clients like a master server
  • network manager got different network setup interface
  • network stream got different constructure scheme
  • permissions checking and algorithm extended and changed
  • starting ability to connect to multiple network nodes at the same time
  • some very much smaller changes here and there
File:
1 edited

Legend:

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

    r9357 r9396  
    1010
    1111   ### File Specific:
    12    main-programmer: Patrick Boenzli
    13    co-programmer: ...
     12   main-programmer: Patrick Boenzli (patrick@orxonox.ethz.ch)
     13   co-programmer: Christoph Renner (rennerc@ee.ethz.ch)
    1414*/
    1515
     
    9898
    9999
     100
     101/**
     102 *  creates a new NetworkStream of server type
     103 * @param port: number of the TCP port
     104 */
     105int NetworkManager::createMasterServer(unsigned int port)
     106{
     107  // init the proxy settings data do this before everything else is done here
     108  NetworkSettings::getInstance()->loadData();
     109
     110  // create the network stream
     111  this->networkStream = new NetworkStream(NET_MASTER_SERVER);
     112  this->networkStream->createServer( port);
     113
     114  // start the network game manager
     115  this->networkStream->createNetworkGameManager();
     116
     117  PRINTF(0)("Created Network Master Server\n");
     118  SDL_Delay(20);
     119  return 1;
     120}
     121
     122/**
     123 *  creates a new network stream of proxy server type
     124 * @param port: number of the TCP port
     125 */
     126int NetworkManager::createProxyServer(unsigned int port)
     127{
     128  // init the proxy settings data do this before everything else is done here
     129  NetworkSettings::getInstance()->loadData();
     130
     131  // create the network stream
     132  this->networkStream = new NetworkStream(NET_PROXY_SERVER_ACTIVE);
     133  this->networkStream->createServer( port);
     134  // and connect to the master server for synchronization
     135//   this->networkStream->connectToMasterServer(NetworkSettings::getInstance()->getMasterAddr());
     136  // and to the other proxy servers
     137
     138
     139
     140  // start the network game manager
     141  this->networkStream->createNetworkGameManager();
     142
     143
     144  PRINTF(0)("Created Network Proxy Server\n");
     145  SDL_Delay(20);
     146  return 1;
     147}
     148
     149
    100150/**
    101151 *  creates a connection from one object to a host
    102152 * @param hostName: the name of the destination host
    103153 */
    104 int NetworkManager::establishConnection(const std::string & name, unsigned int port)
    105 {
    106   this->networkStream = new NetworkStream( name, port );
    107   SharedNetworkData::getInstance()->setDefaultSyncStream(this->networkStream);
     154int NetworkManager::createClient(const std::string & name, unsigned int port)
     155{
     156  // create the network stream
     157  this->networkStream = new NetworkStream(NET_CLIENT);
     158  // connect to the master server, if a redirection should occure, this is handled in the NetworkStream itself
     159  this->networkStream->connectToMasterServer( name, port);
     160
     161  // and start the handshake
    108162  this->networkStream->startHandshake();
     163
     164  PRINTF(0)("Created Network Client");
    109165  return 1;
    110166}
     
    112168
    113169/**
    114  *  creates a new NetworkStream of server type
    115  * @param port: number of the TCP port
    116  */
    117 int NetworkManager::createServer(unsigned int port)
    118 {
    119   SharedNetworkData::getInstance()->setHostID(0);
    120   SharedNetworkData::getInstance()->setNodeType(NET_MASTER_SERVER);
    121   this->networkStream = new NetworkStream(port);
    122   SharedNetworkData::getInstance()->setDefaultSyncStream(this->networkStream);
    123   this->networkStream->createNetworkGameManager();
    124   PRINTF(0)("CREATE SERVER\n");
    125   SDL_Delay(20);
    126   return 1;
    127 }
    128 
    129 
     170 * connects a synchronizeable to the network stream
     171 * @param sync: synchronizeable to connect
     172 */
    130173void NetworkManager::connectSynchronizeable(Synchronizeable& sync)
    131174{
     
    144187  if( likely(this->elapsedTime < 1.0f / NETWORK_FREQUENCY))
    145188    return;
     189
    146190  this->elapsedTime = 0.0f;
    147191
    148   if ( networkStream )
     192  if ( this->networkStream )
    149193    networkStream->processData();
    150194
Note: See TracChangeset for help on using the changeset viewer.