Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6695 in orxonox.OLD for trunk/src/lib/network/network_manager.cc


Ignore:
Timestamp:
Jan 25, 2006, 2:39:53 PM (18 years ago)
Author:
patrick
Message:

merged the network branche to the trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/network/network_manager.cc

    r6341 r6695  
    2020#define DEBUG_MODULE_NETWORK
    2121
    22 
    23 #include "network_stream.h"
    2422#include "class_list.h"
    25 
    2623#include "debug.h"
    27 
     24#include "shell_command.h"
    2825
    2926/* include your own header */
    3027#include "network_manager.h"
     28#include "shared_network_data.h"
     29#include "network_stream.h"
    3130
    3231
    3332/* using namespace std is default, this needs to be here */
    3433using namespace std;
     34
     35SHELL_COMMAND(debug, NetworkManager, debug);
    3536
    3637
     
    4950  this->netStreamList = NULL;
    5051  this->syncList = NULL;
    51   this->tmpStream = NULL;
    52 
    53   this->hostID = -1;
    54   this->bGameServer = false;
     52  this->defaultSyncStream = NULL;
     53  this->sharedNetworkData = SharedNetworkData::getInstance();
    5554
    5655  PRINTF(0)("NetworkManager created\n");
     
    9897  }
    9998
    100   this->tmpStream = new NetworkStream(ipAddress);
     99  this->defaultSyncStream = new NetworkStream(ipAddress);
     100  this->sharedNetworkData->setDefaultSyncStream(this->defaultSyncStream);
     101  this->defaultSyncStream->startHandshake();
    101102  return 1;
    102103}
     
    109110int NetworkManager::createServer(unsigned int port)
    110111{
    111   this->hostID = 0;
    112   this->bGameServer = true;
    113   this->tmpStream = new NetworkStream(port);
    114   this->bGameServer = true;
     112  this->sharedNetworkData->setHostID(0);
     113  this->sharedNetworkData->setGameServer(true);
     114  this->defaultSyncStream = new NetworkStream(port);
     115  this->sharedNetworkData->setDefaultSyncStream(this->defaultSyncStream);
     116  this->defaultSyncStream->createNetworkGameManager();
     117  PRINTF(0)("CREATE SERVER\n");
    115118  SDL_Delay(20);
    116119  return 1;
     
    118121
    119122
    120 /**
    121  *  creates a connection from one object to a host
    122  * @param address: the address of the destination host
    123  * @param synchronizeable: reference to the sync object
    124  */
    125 NetworkStream& NetworkManager::establishConnection(IPaddress& address, Synchronizeable& sync)
    126 {
    127   /* creating a new network stream, it will register itself automaticaly to the class list */
    128   this->tmpStream = new NetworkStream(address);
    129   this->tmpStream->connectSynchronizeable(sync);
    130 }
    131 
    132 
    133 /**
    134  *  teardown a connection
    135  */
    136 void NetworkManager::shutdownConnection()
    137 {
    138   PRINTF(0)("Shutdown connection\n");
    139 }
    140 
    141 
    142123void NetworkManager::connectSynchronizeable(Synchronizeable& sync)
    143124{
    144   this->tmpStream->connectSynchronizeable(sync);
     125  if( this->defaultSyncStream)
     126    this->defaultSyncStream->connectSynchronizeable(sync);
    145127}
    146128
     
    157139      if( static_cast<NetworkStream*>(*stream)->isActive())
    158140        static_cast<NetworkStream*>(*stream)->processData();
    159 
    160141  }
    161 
    162142}
    163143
     144
     145
    164146/**
    165  * Sets the hostID to a specific number
    166  * @param id: The new ID
     147 * debug output
    167148 */
    168 void NetworkManager::setHostID(int id)
     149 void NetworkManager::debug()
    169150{
    170     this->hostID = id;
     151  PRINT(0)("=================Network::debug()=========\n");
     152  this->defaultSyncStream->debug();
     153  PRINT(0)("===========================================\n");
    171154}
Note: See TracChangeset for help on using the changeset viewer.