Changeset 9656 in orxonox.OLD for trunk/src/lib/network/monitor/network_monitor.cc
- Timestamp:
- Aug 4, 2006, 11:01:28 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/network/monitor/network_monitor.cc
r9494 r9656 10 10 11 11 ### File Specific: 12 main-programmer: Patrick Boenzli 12 main-programmer: Patrick Boenzli (patrick@orxonox.ethz.ch) 13 13 */ 14 14 … … 49 49 this->networkStream = networkStream; 50 50 this->playerNumber = 0; 51 this->connectionNumber = 0; 51 52 // create the localnode, init it and add it to the nodes list 52 53 this->localNode = new NetworkNode( this->networkStream->getPeerInfo()); … … 66 67 PeerInfo* peer = new PeerInfo(); 67 68 peer->ip = (*it); 68 peer->nodeType = NET_PROXY_SERVER_ ACTIVE;69 peer->nodeType = NET_PROXY_SERVER_PASSIVE; 69 70 peer->userId = -1; 70 71 71 NetworkNode* node = new NetworkNode(peer);72 this->addNode( node);73 72 this->addActiveProxyServer( this->localNode, peer); 74 73 } … … 141 140 return; 142 141 142 PRINTF(0)("^^^^^^^^^^^^^^^^^^^^^^^^^^ adding node: %i with type: %s\n\n", pInfo->userId, pInfo->getNodeTypeString().c_str()); 143 143 144 if( pInfo->isClient()) 144 this->localNode->addClient(pInfo); 145 { 146 this->localNode->addClient(new NetworkNode(pInfo)); 147 } 145 148 else if( pInfo->isProxyServerActive()) 146 149 { 147 this->localNode->addActiveProxyServer(pInfo); 148 // create a new node, since a proxy can connect clients again 149 NetworkNode* node = new NetworkNode(pInfo); 150 this->nodeList.push_back(node); 150 this->localNode->addActiveProxyServer(new NetworkNode(pInfo)); 151 } 152 else if( pInfo->isProxyServerActivePassive()) 153 { 154 this->localNode->addPassiveProxyServer(new NetworkNode(pInfo)); 151 155 } 152 156 else if( pInfo->isMasterServer()) 153 157 { 154 this->localNode->addMasterServer(pInfo); 155 } 158 this->localNode->addMasterServer(new NetworkNode(pInfo)); 159 } 160 else 161 assert(false); 156 162 } 157 163 … … 168 174 169 175 if( pInfo->isClient()) 170 node->addClient( pInfo);176 node->addClient(new NetworkNode(pInfo)); 171 177 else if( pInfo->isProxyServerActive()) 172 node->addActiveProxyServer( pInfo);178 node->addActiveProxyServer(new NetworkNode(pInfo)); 173 179 else if( pInfo->isMasterServer()) 174 node->addMasterServer(pInfo); 180 node->addMasterServer(new NetworkNode(pInfo)); 181 } 182 183 184 185 /** 186 * removes a node from the network monitor 187 * @param pInfo the node to remove 188 */ 189 void NetworkMonitor::removeNode(PeerInfo* pInfo) 190 { 191 this->removeNode(this->localNode, pInfo); 192 } 193 194 195 /** 196 * removes the network node 197 * @param node the network node where the PeerInfo node is connected to 198 * @param pInfo the PeerInfo to remove 199 */ 200 void NetworkMonitor::removeNode(NetworkNode* node, PeerInfo* pInfo) 201 { 202 if( node == NULL || pInfo == NULL) 203 return; 204 205 if( pInfo->isClient()) 206 node->removeClient(pInfo->userId); 207 else if( pInfo->isProxyServerActive()) 208 node->removeActiveProxyServer(pInfo->userId); 209 else if( pInfo->isMasterServer()) 210 node->removeMasterServer(pInfo->userId); 175 211 } 176 212 … … 197 233 198 234 /** 235 * @param userId of the searched node 236 * @returns the PeerInfo of the userId peer 237 */ 238 PeerInfo* NetworkMonitor::getPeerByUserId( int userId) 239 { 240 NetworkNode* node = this->getNodeByUserId(userId); 241 if( node != NULL) 242 return node->getPeerInfo(); 243 244 return NULL; 245 } 246 247 /** 248 * searches for a given NetworkNode 249 * @param userId of the searched node 250 * @returns the PeerInfo of the userId peer 251 */ 252 NetworkNode* NetworkMonitor::getNodeByUserId( int userId) 253 { 254 std::list<NetworkNode*>::iterator it = this->nodeList.begin(); 255 NetworkNode* node = NULL; 256 for(; it != this->nodeList.end(); it++) 257 { 258 node = (*it)->getNodeByUserId(userId); 259 if( node != NULL) 260 return node; 261 } 262 263 return NULL; 264 } 265 266 267 /** 199 268 * this displays the network monitor gui 200 269 */ … … 203 272 if (this->box == NULL) 204 273 { 205 this->box = new OrxGui::GLGuiBox(OrxGui::Vertical); 206 { 207 NetworkStatsWidget* netStats = new NetworkStatsWidget(this); 208 this->box->pack(netStats); 209 210 } 211 274 this->box = new NetworkStatsWidget(this); 212 275 this->box->showAll(); 213 this->box->setAbsCoor2D(300, 40);214 276 } 215 277 else … … 251 313 for(; it != this->nodeList.end(); it++) 252 314 { 253 (*it)->debug( 0);315 (*it)->debug(1); 254 316 } 255 317
Note: See TracChangeset
for help on using the changeset viewer.