- Timestamp:
- May 23, 2006, 4:35:08 PM (19 years ago)
- Location:
- branches/network/src/lib/network
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/connection_monitor.cc
r7772 r7778 33 33 this->incomingUnzippedBandWidth = 0; 34 34 this->outgoingUnzippedBandWidth = 0; 35 this->incomingZippedBandWidth = 0;36 this->outgoingZippedBandWidth = 0;37 35 this->nIncomingPackets = 0; 38 36 this->nOutgoingPackets = 0; … … 64 62 65 63 for ( int i = 0; i < length; i++ ) 66 {67 64 if ( data[i] == '\0' ) 68 65 nZeroBytes++; 69 }70 66 71 67 NETPRINTF(n)( "ZEROBYTES: %d (%f%%)\n", nZeroBytes, ((float)100)*nZeroBytes/length ); … … 86 82 } 87 83 88 //TODO cleanup list 89 // while ( sentStateTicks.begin()->first <= ackedState ) 90 // { 91 // NETPRINTF(n)("removing old state\n"); 92 // sentStateTicks.erase( sentStateTicks.begin() ); 93 // } 94 95 NETPRINTF(n)("adsf\n"); 84 while ( sentStateTicks.begin()->first <= ackedState ) 85 sentStateTicks.erase( sentStateTicks.begin() ); 96 86 97 //TODO cleanup list98 #if 099 87 while ( ackDelay.size() > N_PACKETS_FOR_PING ) 100 {101 NETPRINTF(n)("removing old ackdelay\n");102 88 ackDelay.erase( ackDelay.begin() ); 103 }104 #endif105 89 106 90 ping = 0; … … 128 112 // delete old packets 129 113 while ( packetHistory.begin()->first < tick - MSECS_TO_CALC_BWIDTH ) 130 {131 114 packetHistory.erase( packetHistory.begin() ); 132 }133 115 134 116 float res = 0.0f; … … 149 131 } 150 132 151 /**152 * calculates max packet size you can send now to fit into bandwidth153 * @return154 */155 int ConnectionMonitor::getMaxPacketSize( )156 {157 }158 133 159 -
branches/network/src/lib/network/connection_monitor.h
r7776 r7778 24 24 void processUnzippedOutgoingPacket( byte * data, int length, int stateId ); 25 25 void processUnzippedIncomingPacket( byte * data, int length, int stateId, int ackedState ); 26 26 void processZippedPacket( ); 27 27 28 28 void calculatePing(); 29 29 30 //TODO 31 bool hasTimedOut(){ return false; return ( lastPacketTick + SECS_TO_TIMEOUT*1000 < SDL_GetTicks() ) && nIncomingPackets > 0; } 32 33 int getMaxPacketSize(); 30 bool hasTimedOut(){ return ( lastPacketTick + SECS_TO_TIMEOUT*1000 < SDL_GetTicks() ) && nIncomingPackets > 0; } 34 31 35 32 private: … … 43 40 std::map<int,int> outgoingUnzippedPacketHistory; 44 41 45 std::map<int,int> incomingZippedPacketHistory;46 std::map<int,int> outgoingZippedPacketHistory;47 48 42 std::list<int> ackDelay; 49 43 int ping; … … 51 45 float incomingUnzippedBandWidth; 52 46 float outgoingUnzippedBandWidth; 53 54 float incomingZippedBandWidth;55 float outgoingZippedBandWidth;56 47 57 48 int nIncomingPackets; -
branches/network/src/lib/network/handshake.cc
r7777 r7778 22 22 #include "handshake.h" 23 23 24 #include "network_log.h"25 26 24 #include <cassert> 27 25 … … 43 41 errorString_handler = registerVarId( new SynchronizeableString( &localState.errorString, &remoteState.errorString, "errorString", PERMISSION_ALL ) ); 44 42 45 localState.completed = 0;43 localState.completed = false; 46 44 localState.error = 0; 47 45 localState.errorString = ""; … … 52 50 localState.version = _ORXONOX_VERSION; 53 51 54 remoteState.completed = 0;52 remoteState.completed = false; 55 53 remoteState.error = 0; 56 54 remoteState.errorString = ""; … … 78 76 { 79 77 localState.error = 1; 80 localState.completed = 1; 81 PRINTF(0)("orxId: %d:%d", remoteState.orxId, _ORXONOX_ID); 82 localState.errorString = "Seems not to be orxonox!\n"; 78 localState.completed = true; 79 localState.errorString = "Seems not to be orxonox!"; 83 80 return; 84 81 } 85 82 else 86 if ( remoteState.version -= _ORXONOX_VERSION ) 87 localState.completed = 1; 83 localState.completed = true; 88 84 } 89 85 … … 93 89 { 94 90 localState.error = 2; 95 localState.completed = 1; 96 PRINTF(0)("version: %d:%d", remoteState.version, _ORXONOX_VERSION); 97 localState.errorString = "Versions of server and client do not match!\n"; 91 localState.completed = true; 92 localState.errorString = "Versions of server and client do not match!"; 98 93 return; 99 94 } 100 95 else 101 if ( remoteState.orxId == _ORXONOX_ID ) 102 localState.completed = 1; 96 localState.completed = true; 103 97 } 104 98 105 99 } 106 107 PRINTF(0)("=======================BEGIN=============================\n");108 for ( std::list<int>::iterator it = id.begin(); it != id.end(); it++ )109 {110 if ( *it == netManId_handler )111 PRINTF(0)("netManId_handler\n");112 if ( *it == msgManId_handler )113 PRINTF(0)("msgManId_handler\n");114 if ( *it == hostId_handler )115 PRINTF(0)("hostId_handler\n");116 if ( *it == completed_handler )117 PRINTF(0)("completed_handler\n");118 if ( *it == error_handler )119 PRINTF(0)("error_handler\n");120 if ( *it == errorString_handler )121 PRINTF(0)("errorString_handler\n");122 if ( *it == orxId_handler )123 PRINTF(0)("orxId_handler\n");124 if ( *it == version_handler )125 PRINTF(0)("version_handler\n");126 }127 PRINTF(0)("=========================================================\n");128 100 } 129 101 -
branches/network/src/lib/network/handshake.h
r7777 r7778 39 39 inline int getMessageManagerId(){ return remoteState.messageManagerId; } 40 40 inline void doReject( std::string reason ){ localState.error = 1; localState.errorString = "the server rejected your connection ["+ reason +"]"; } 41 inline std::string getErrorString(){ return remoteState.errorString; }42 41 43 42 virtual void varChangeHandler( std::list<int> & id ); -
branches/network/src/lib/network/network_game_manager.cc
r7772 r7778 467 467 { 468 468 /* create new playable for Player*/ 469 470 assert ( SharedNetworkData::getInstance()->isGameServer() );471 472 469 PRINTF(0)("Request for creation: %i\n", userId); 473 470 int uniqueId = this->createEntity(CL_SPACE_SHIP, userId); -
branches/network/src/lib/network/network_log.h
r7770 r7778 9 9 #include "netdefs.h" 10 10 #include "debug.h" 11 11 #include "SDL_net.h" 12 12 13 13 #include <string> … … 44 44 /** @returns a Pointer to the only object of this Class */ 45 45 inline static NetworkLog* getInstance(void) { if (!singletonRef) singletonRef = new NetworkLog(); return singletonRef; }; 46 46 47 47 bool listen( int port ); 48 48 49 49 void printfnet( ); 50 50 51 51 void printfn( char * format, ... ); 52 52 void printf0( char * format, ... ); … … 59 59 private: 60 60 NetworkLog(); 61 61 62 62 void acceptNewConnections(); 63 63 64 64 static NetworkLog* singletonRef; 65 65 66 66 TCPsocket listensock; 67 67 std::list<TCPsocket> sockets; 68 68 69 69 char buf[NETWORK_LOG_BUFLEN]; 70 70 }; -
branches/network/src/lib/network/network_stream.cc
r7777 r7778 336 336 this->networkGameManager->setUniqueID( it->second.handshake->getNetworkGameManagerId() ); 337 337 MessageManager::getInstance()->setUniqueID( it->second.handshake->getMessageManagerId() ); 338 339 } 340 else 341 handleNewClient( it->second.userId ); 342 343 PRINTF(0)("handshake finished id=%d\n", it->second.handshake->getNetworkGameManagerId()); 338 } 339 340 PRINT(0)("handshake finished id=%d\n", it->second.handshake->getNetworkGameManagerId()); 344 341 345 342 delete it->second.handshake; 346 343 it->second.handshake = NULL; 347 344 345 handleNewClient( it->second.userId ); 348 346 } 349 347 else 350 348 { 351 PRINT F(1)("handshake failed: %s!\n", it->second.handshake->getErrorString().c_str());349 PRINT(1)("handshake failed!\n"); 352 350 it->second.socket->disconnectServer(); 353 it->second.socket = NULL;354 355 delete it->second.handshake;356 it->second.handshake = NULL;357 351 } 358 352 } … … 426 420 } 427 421 428 NETPRINTF(0)("adsf\n");429 430 422 assert( Converter::intToByteArray( offset, buf, INTSIZE ) == INTSIZE ); 431 423 432 NETPRINTF(0)("adsf %d\n", offset);433 434 424 assert( peer->second.socket->writePacket( buf, offset ) ); 435 425 436 NETPRINTF(0)("adsf\n"); 437 438 //peer->second.connectionMonitor->processUnzippedOutgoingPacket( buf, offset, currentState ); 426 peer->second.connectionMonitor->processUnzippedOutgoingPacket( buf, offset, currentState ); 439 427 440 428 NETPRINTF(n)("send packet: %d userId = %d\n", offset, peer->second.userId); … … 524 512 if ( !peers[peer->second.userId].isServer ) 525 513 { 526 PRINTF(0)("Client %d is no server: dont accept new synchronizeable\n", peer->second.userId);527 514 offset += syncDataLength; 528 515 continue; … … 583 570 } 584 571 585 //peer->second.connectionMonitor->processUnzippedIncomingPacket( buf, offset, currentState, ackedState );572 peer->second.connectionMonitor->processUnzippedIncomingPacket( buf, offset, currentState, ackedState ); 586 573 587 574 peer->second.lastAckedState = ackedState; … … 610 597 void NetworkStream::cleanUpOldSyncList( ) 611 598 { 612 //TODO dont return do something613 return;614 599 int now = SDL_GetTicks(); 615 600 -
branches/network/src/lib/network/udp_socket.cc
r7777 r7778 17 17 #include "udp_server_socket.h" 18 18 19 #include "network_log.h"20 19 21 20 void UdpSocket::init( ) … … 152 151 bool UdpSocket::writePacket( byte * data, int length ) 153 152 { 154 NETPRINTF(0)("adsf\n");155 153 if ( serverSocket ) 156 154 { 157 NETPRINTF(0)("adsf\n");158 155 NetworkPacket networkPacket; 159 156 networkPacket.length = length; 160 157 networkPacket.data = data; 161 NETPRINTF(0)("adsf\n");162 158 if ( !serverSocket->sendPacket( networkPacket, this->userId ) ) 163 159 { 164 NETPRINTF(0)("adsf\n");165 160 bOk = false; 166 161 return false; 167 162 } 168 163 else 169 {170 NETPRINTF(0)("adsf\n");171 164 return true; 172 }173 NETPRINTF(0)("adsf\n");174 165 } 175 166 else 176 167 { 177 if ( !socket )178 return false;179 180 NETPRINTF(0)("adsf\n");181 168 assert( length <= packet->maxlen ); 182 169 183 NETPRINTF(0)("adsf\n");184 170 memcpy( packet->data, data, length ); 185 NETPRINTF(0)("adsf\n");186 171 packet->len = length; 187 172 188 NETPRINTF(0)("adsf\n");189 173 if ( SDLNet_UDP_Send( socket, 1, packet) == 0 ) 190 174 { 191 NETPRINTF(0)("adsf\n");192 175 PRINTF(1)("SDLNet_UDP_Send: %s\n", SDLNet_GetError()); 193 176 bOk = false; … … 195 178 } 196 179 197 NETPRINTF(0)("adsf\n");198 180 return true; 199 181 } 200 NETPRINTF(0)("adsf\n");201 182 } 202 183
Note: See TracChangeset
for help on using the changeset viewer.