Changeset 9406 in orxonox.OLD for trunk/src/lib/network/network_manager.cc
- Timestamp:
- Jul 24, 2006, 11:09:47 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/network/network_manager.cc
r9059 r9406 10 10 11 11 ### 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) 14 14 */ 15 15 … … 34 34 35 35 /* using namespace std is default, this needs to be here */ 36 using namespace std; 36 37 37 38 38 SHELL_COMMAND(debug, NetworkManager, debug); … … 53 53 this->networkStream = NULL; 54 54 this->elapsedTime = 0.0f; 55 56 55 56 57 57 int port = Preferences::getInstance()->getInt( "network", "telnetport", 0 ); 58 58 59 59 if ( port > 0 ) 60 60 NetworkLog::getInstance()->listen( port ); … … 75 75 this->networkStream = NULL; 76 76 } 77 77 78 78 NetworkManager::singletonRef = NULL; 79 79 } … … 95 95 { 96 96 97 } 98 99 100 101 /** 102 * creates a new NetworkStream of server type 103 * @param port: number of the TCP port 104 */ 105 int NetworkManager::createMasterServer(unsigned int port) 106 { 107 // load the network settings 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 */ 126 int NetworkManager::createProxyServer(unsigned int port) 127 { 128 // load the network settings 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; 97 147 } 98 148 … … 102 152 * @param hostName: the name of the destination host 103 153 */ 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); 154 int NetworkManager::createClient(const std::string & name, unsigned int port) 155 { 156 // load the network settings 157 NetworkSettings::getInstance()->loadData(); 158 159 // create the network stream 160 this->networkStream = new NetworkStream(NET_CLIENT); 161 // connect to the master server, if a redirection should occure, this is handled in the NetworkStream itself 162 this->networkStream->connectToMasterServer( name, port); 163 164 // and start the handshake 108 165 this->networkStream->startHandshake(); 166 167 PRINTF(0)("Created Network Client"); 109 168 return 1; 110 169 } … … 112 171 113 172 /** 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()->setGameServer(true); 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 173 * connects a synchronizeable to the network stream 174 * @param sync: synchronizeable to connect 175 */ 130 176 void NetworkManager::connectSynchronizeable(Synchronizeable& sync) 131 177 { … … 144 190 if( likely(this->elapsedTime < 1.0f / NETWORK_FREQUENCY)) 145 191 return; 192 146 193 this->elapsedTime = 0.0f; 147 194 148 if ( networkStream )195 if ( this->networkStream ) 149 196 networkStream->processData(); 150 197 151 198 NetworkGameManager::getInstance()->tick( this->elapsedTime ); 152 199 }
Note: See TracChangeset
for help on using the changeset viewer.