Changeset 6018 in orxonox.OLD for branches/network
- Timestamp:
- Dec 10, 2005, 6:48:01 PM (19 years ago)
- Location:
- branches/network/src
- Files:
-
- 8 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 -
branches/network/src/subprojects/network/network_unit_test.cc
r5996 r6018 42 42 NetworkSocket client1(ip); 43 43 44 NetworkSocket server1 = server.getNewSocket();44 NetworkSocket* server1 = server.getNewSocket(); 45 45 46 46 NetworkSocket client2(ip); 47 47 48 NetworkSocket server2 = server.getNewSocket();48 NetworkSocket* server2 = server.getNewSocket(); 49 49 50 50 char buf[1024]; … … 63 63 n = client1.writePacket((byte*)str1, strlen(str1)+1); 64 64 printf("%d bytes send from client1\n", n); 65 n = server1 .writePacket((byte*)str2, strlen(str2)+1);65 n = server1->writePacket((byte*)str2, strlen(str2)+1); 66 66 printf("%d bytes send from server1\n", n); 67 67 n = client2.writePacket((byte*)str3, strlen(str3)+1); 68 68 printf("%d bytes send from client2\n", n); 69 n = server2 .writePacket((byte*)str4, strlen(str4)+1);69 n = server2->writePacket((byte*)str4, strlen(str4)+1); 70 70 printf("%d bytes send from server2\n", n); 71 71 SDL_Delay(1000); 72 72 73 73 printf("read from server1\n"); 74 n = server1 .readPacket((byte*)buf, 1024);74 n = server1->readPacket((byte*)buf, 1024); 75 75 printf("read %d bytes\n", n); 76 76 if (n<0) … … 80 80 81 81 printf("read from server2\n"); 82 n = server2 .readPacket((byte*)buf, 1024);82 n = server2->readPacket((byte*)buf, 1024); 83 83 printf("read %d bytes\n", n); 84 84 if (n<0) … … 108 108 printf("result: %d\n", client1.writePacket((byte*)buf, 1000)); 109 109 110 server1 .writePacket((byte*)str1, strlen(str1)+1);110 server1->writePacket((byte*)str1, strlen(str1)+1); 111 111 SDL_Delay(500); 112 112 printf("try to read with a too small buffer\n"); -
branches/network/src/util/loading/game_loader.h
r5982 r6018 47 47 ErrorMessage init(); 48 48 ErrorMessage loadCampaign(const char* name); 49 ErrorMessage loadNetworkCampaign(const char* fileName); 49 50 ErrorMessage start(); 50 51 void stop(); … … 66 67 67 68 Campaign* fileToCampaign(const char* name); 69 Campaign* fileToNetworkCampaign(const char* fileName); 68 70 69 71 private:
Note: See TracChangeset
for help on using the changeset viewer.