Changeset 6018 in orxonox.OLD for branches/network/src/lib
- Timestamp:
- Dec 10, 2005, 6:48:01 PM (19 years ago)
- Location:
- branches/network/src/lib/network
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/network_manager.h
r5997 r6018 47 47 inline int getHostID() { return this->hostID; }; 48 48 49 private: 49 50 50 void connectSynchronizeable(Synchronizeable& sync); 51 51 void synchronize(); 52 52 53 private: 53 54 NetworkManager(); 54 55 -
branches/network/src/lib/network/network_socket.h
r5996 r6018 87 87 int readPacket(byte * data, int maxLength); 88 88 89 inline bool isOk() { return tcpSocket!=NULL; } 90 89 91 }; 90 92 -
branches/network/src/lib/network/network_stream.cc
r6007 r6018 66 66 this->networkProtocol = new NetworkProtocol(); 67 67 this->connectionMonitor = new ConnectionMonitor(); 68 this->networkSockets.push_back( NULL ); 69 this->bActive = true; 68 70 } 69 71 … … 111 113 void NetworkStream::processData() 112 114 { 115 printf("processData()"); 116 if ( this->type == NET_SERVER ) 117 this->updateConnectionList(); 118 113 119 #if 0 114 120 int dataLength = 0; … … 178 184 #endif 179 185 } 186 187 void NetworkStream::updateConnectionList( ) 188 { 189 //check for new connections 190 NetworkSocket* tempNetworkSocket = serverSocket->getNewSocket(); 191 192 if ( tempNetworkSocket ) 193 { 194 int clientId; 195 if ( freeSocketSlots.size() >0 ) 196 { 197 clientId = freeSocketSlots.back(); 198 freeSocketSlots.pop_back(); 199 networkSockets[clientId] = tempNetworkSocket; 200 } else 201 { 202 networkSockets.push_back(tempNetworkSocket); 203 clientId = networkSockets.size(); 204 } 205 206 PRINTF(0)("New Client: %s", clientId); 207 //TODO: start handshake 208 //new Handshake(true, clientId); 209 } 210 211 212 //check if connections are ok else remove them 213 for ( int i = 1; i<networkSockets.size(); i++) 214 { 215 if ( networkSockets[i] && !networkSockets[i]->isOk() ) 216 { 217 //TODO: tell EntityManager that this player left the game 218 219 delete networkSockets[i]; 220 networkSockets[i] = NULL; 221 222 if ( i == networkSockets.size()-1 ) 223 { 224 networkSockets.pop_back(); 225 } 226 else 227 { 228 freeSocketSlots.push_back(i); 229 } 230 } 231 } 232 233 } -
branches/network/src/lib/network/network_stream.h
r6007 r6018 51 51 Header packetHeader; 52 52 bool bActive; 53 std::list<int> freeSocketSlots; 54 55 void updateConnectionList(); 53 56 }; 54 57 #endif /* _NETWORK_STREAM */ -
branches/network/src/lib/network/server_socket.cc
r6007 r6018 110 110 111 111 112 NetworkSocket ServerSocket::getNewSocket( )112 NetworkSocket* ServerSocket::getNewSocket( ) 113 113 { 114 114 if ( !listenSocket ) … … 127 127 else 128 128 { 129 return NetworkSocket(sock);129 return new NetworkSocket(sock); 130 130 } 131 131 } -
branches/network/src/lib/network/server_socket.h
r6007 r6018 39 39 ~ServerSocket(); 40 40 bool listen( unsigned int port ); 41 NetworkSocket getNewSocket( void );41 NetworkSocket* getNewSocket( void ); 42 42 void close(); 43 inline bool isOk(){ return listenSocket!=NULL; } 43 44 }; 44 45
Note: See TracChangeset
for help on using the changeset viewer.