Changeset 6695 in orxonox.OLD for trunk/src/lib/network/network_manager.cc
- Timestamp:
- Jan 25, 2006, 2:39:53 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/network/network_manager.cc
r6341 r6695 20 20 #define DEBUG_MODULE_NETWORK 21 21 22 23 #include "network_stream.h"24 22 #include "class_list.h" 25 26 23 #include "debug.h" 27 24 #include "shell_command.h" 28 25 29 26 /* include your own header */ 30 27 #include "network_manager.h" 28 #include "shared_network_data.h" 29 #include "network_stream.h" 31 30 32 31 33 32 /* using namespace std is default, this needs to be here */ 34 33 using namespace std; 34 35 SHELL_COMMAND(debug, NetworkManager, debug); 35 36 36 37 … … 49 50 this->netStreamList = NULL; 50 51 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(); 55 54 56 55 PRINTF(0)("NetworkManager created\n"); … … 98 97 } 99 98 100 this->tmpStream = new NetworkStream(ipAddress); 99 this->defaultSyncStream = new NetworkStream(ipAddress); 100 this->sharedNetworkData->setDefaultSyncStream(this->defaultSyncStream); 101 this->defaultSyncStream->startHandshake(); 101 102 return 1; 102 103 } … … 109 110 int NetworkManager::createServer(unsigned int port) 110 111 { 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"); 115 118 SDL_Delay(20); 116 119 return 1; … … 118 121 119 122 120 /**121 * creates a connection from one object to a host122 * @param address: the address of the destination host123 * @param synchronizeable: reference to the sync object124 */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 connection135 */136 void NetworkManager::shutdownConnection()137 {138 PRINTF(0)("Shutdown connection\n");139 }140 141 142 123 void NetworkManager::connectSynchronizeable(Synchronizeable& sync) 143 124 { 144 this->tmpStream->connectSynchronizeable(sync); 125 if( this->defaultSyncStream) 126 this->defaultSyncStream->connectSynchronizeable(sync); 145 127 } 146 128 … … 157 139 if( static_cast<NetworkStream*>(*stream)->isActive()) 158 140 static_cast<NetworkStream*>(*stream)->processData(); 159 160 141 } 161 162 142 } 163 143 144 145 164 146 /** 165 * Sets the hostID to a specific number 166 * @param id: The new ID 147 * debug output 167 148 */ 168 void NetworkManager::setHostID(int id)149 void NetworkManager::debug() 169 150 { 170 this->hostID = id; 151 PRINT(0)("=================Network::debug()=========\n"); 152 this->defaultSyncStream->debug(); 153 PRINT(0)("===========================================\n"); 171 154 }
Note: See TracChangeset
for help on using the changeset viewer.