Changeset 5829 in orxonox.OLD for branches/network/src/lib/network/network_manager.cc
- Timestamp:
- Nov 30, 2005, 9:43:05 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/network_manager.cc
r5822 r5829 35 35 36 36 37 /************************************ 38 What you will see here are the function definitions from the header file (network_manager.h) with doxygen documentation. Here is an example: 39 40 41 In file network_manager.h 42 43 class NetworkManager 44 { 45 int doSomeStuff(float argument, float* pointer); 46 } 47 48 will be implemented in the source file as follows: 49 50 In file network_manager.cc 51 52 / ** 53 * this is the short description for this function: it just does some stuff 54 * @param argument: this is the first argument, stuff... 55 * @param pointer: this is the pointer to nowhereland 56 * return: whatever the function returns: for example an index, number, etc. 57 * / 58 int NetworkManager::doSomeStuff(float argument, float* pointer) 59 { 60 // whaterver you want to do 61 } 62 63 64 if you want to make automake compile your files: you will want to add the file names to the local Makefile.am 65 66 ************************************/ 67 68 37 NetworkManager* NetworkManager::singletonRef = NULL; 69 38 70 39 /** … … 79 48 this->netStreamList = NULL; 80 49 this->syncList = NULL; 50 this->tmpStream = NULL; 81 51 82 52 PRINTF(0)("NetworkManager created\n"); … … 114 84 * creates a connection from one object to a host 115 85 * @param hostName: the name of the destination host 116 * @param synchronizeable: reference to the sync object117 86 */ 118 NetworkStream& establishConnection(const char& hostName, const Synchronizeable& sync) 119 {} 87 int NetworkManager::establishConnection(const char* name, unsigned int port) 88 { 89 IPaddress ipAddress; 90 int error = SDLNet_ResolveHost(&ipAddress, name, port); 91 if( error == -1) { 92 printf("\n\nerror on address resolution, program inconsistency\n\n"); 93 return -1; 94 } 95 96 this->tmpStream = new NetworkStream(ipAddress, NET_CLIENT); 97 return 1; 98 } 99 100 101 /** 102 * creates a new NetworkStream of server type 103 * @param port: number of the TCP port 104 */ 105 int NetworkManager::createServer(unsigned int port) 106 { 107 this->tmpStream = new NetworkStream(port, NET_SERVER); 108 SDL_Delay(20); 109 return 1; 110 } 120 111 121 112 … … 127 118 NetworkStream& NetworkManager::establishConnection(IPaddress& address, Synchronizeable& sync) 128 119 { 129 printf("Establish connection to server %s, on port %u\n", SDLNet_ResolveIP(&address), address.port);130 120 /* creating a new network stream, it will register itself automaticaly to the class list */ 131 NetworkStream* netStream = new NetworkStream(address, sync, NET_CLIENT);121 this->tmpStream = new NetworkStream(address, sync, NET_CLIENT); 132 122 } 123 133 124 134 125 /** … … 140 131 PRINTF(0)("Create a new server socket\n"); 141 132 /* creating a new network stream, it will register itself automaticaly to the class list */ 142 NetworkStream* netStream = new NetworkStream(port, sync, NET_SERVER);133 this->tmpStream = new NetworkStream(port, sync, NET_SERVER); 143 134 } 144 135 … … 153 144 154 145 146 void NetworkManager::connectSynchronizeable(Synchronizeable& sync) 147 { 148 this->tmpStream->connectSynchronizeable(sync); 149 } 150 155 151 156 152 /** … … 161 157 if (this->netStreamList != NULL || (this->netStreamList = ClassList::getList(CL_NETWORK_STREAM)) != NULL) 162 158 { 159 // tIterator<BaseObject>* iterator = this->netStreamList->getIterator(); 160 // NetworkStream* stream = (NetworkStream*)(iterator->firstElement()); 161 // while( stream) 162 // { 163 // if(stream->isActive()) 164 // stream->processData(); 165 // stream = (NetworkStream*)(iterator->nextElement()); 166 // } 167 // delete iterator; 163 168 std::list<BaseObject*>::iterator stream; 164 169 for (stream = this->netStreamList->begin(); stream != this->netStreamList->end(); ++stream) 165 static_cast<NetworkStream*>(*stream)->processData(); 170 if( static_cast<NetworkStream*>(*stream)->isActive()) 171 static_cast<NetworkStream*>(*stream)->processData(); 172 166 173 } 167 174
Note: See TracChangeset
for help on using the changeset viewer.