Changeset 6025 in orxonox.OLD for branches/network
- Timestamp:
- Dec 10, 2005, 9:07:46 PM (19 years ago)
- Location:
- branches/network/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/network_socket.cc
r5996 r6025 28 28 #include "debug.h" 29 29 30 static SDL_mutex* threadTerminationMutex = SDL_CreateMutex(); 30 31 31 32 /** … … 65 66 outgoingBufferLength = 0; 66 67 68 #ifdef _USE_OUTGOING_BUFFER 69 thread_write_running = false; 70 #endif 71 thread_read_running = false; 72 67 73 incomingBufferMutex = SDL_CreateMutex(); 68 74 outgoingBufferMutex = SDL_CreateMutex(); 75 76 69 77 socketMutex = SDL_CreateMutex(); 70 78 terminateThread = false; … … 89 97 * Default destructor 90 98 */ 91 NetworkSocket::~ NetworkSocket( ) 92 { 99 NetworkSocket::~NetworkSocket( ) 100 { 101 this->terminateThread = true; 93 102 /* Quit SDL_net */ 94 103 // NOTE: what if other instances of NetworkSocket running? … … 275 284 if (nbytesread<=0) 276 285 { 277 printf("SDLNet_TCP_Recv: %s\n", SDLNet_GetError()); 286 if (nbytesread<0) 287 printf("SDLNet_TCP_Recv: %s\n", SDLNet_GetError()); 278 288 279 289 SDL_mutexP(self->socketMutex); … … 295 305 } 296 306 307 SDL_mutexP(threadTerminationMutex); 308 self->thread_read_running = false; 309 310 if ( !self->thread_write_running ) 311 delete self; 312 SDL_mutexV(threadTerminationMutex); 313 314 printf("QUIT READ THREAD\n"); 297 315 return 0; 298 316 } … … 347 365 } 348 366 367 SDL_mutexP(threadTerminationMutex); 368 self->thread_write_running = false; 369 370 if ( !self->thread_read_running ) 371 delete self; 372 SDL_mutexV(threadTerminationMutex); 373 349 374 printf("QUIT WRITE THREAD\n"); 350 375 return 0; -
branches/network/src/lib/network/network_socket.h
r6018 r6025 63 63 bool terminateThread; 64 64 65 static SDL_mutex* threadTerminationMutex; 65 66 static int thread_read(void * data); 67 bool thread_read_running; 66 68 #ifdef _USE_OUTGOING_BUFFER 67 69 static int thread_write(void * data); 70 bool thread_write_running; 68 71 #endif 69 72 … … 74 77 void init(); 75 78 79 //dont make this public use destroy() instead 80 ~NetworkSocket(); 81 76 82 public: 77 83 … … 79 85 NetworkSocket(IPaddress ip); 80 86 NetworkSocket(TCPsocket sock); 81 ~NetworkSocket(); 87 void destroy() { terminateThread = true; }; 88 82 89 83 90 void connectToServer(IPaddress ip); -
branches/network/src/lib/network/network_stream.cc
r6018 r6025 93 93 { 94 94 (*i)->disconnectServer(); 95 delete *i;95 (*i)->destroy(); 96 96 } 97 97 } … … 113 113 void NetworkStream::processData() 114 114 { 115 printf("processData()");115 //PRINTF(0)("processData()\n"); 116 116 if ( this->type == NET_SERVER ) 117 117 this->updateConnectionList(); … … 188 188 { 189 189 //check for new connections 190 190 191 NetworkSocket* tempNetworkSocket = serverSocket->getNewSocket(); 191 192 … … 200 201 } else 201 202 { 203 clientId = networkSockets.size(); 202 204 networkSockets.push_back(tempNetworkSocket); 203 clientId = networkSockets.size(); 204 } 205 206 PRINTF(0)("New Client: %s", clientId); 205 } 206 207 PRINTF(0)("New Client: %d\n", clientId); 207 208 //TODO: start handshake 208 209 //new Handshake(true, clientId); … … 216 217 { 217 218 //TODO: tell EntityManager that this player left the game 218 219 delete networkSockets[i]; 219 PRINTF(0)("Client is gone: %d\n", i); 220 221 //delete networkSockets[i]; 222 networkSockets[i]->destroy(); 220 223 networkSockets[i] = NULL; 221 224 … … 231 234 } 232 235 233 } 236 237 } -
branches/network/src/subprojects/network/network_unit_test.cc
r6018 r6025 196 196 { 197 197 netMan->synchronize(); 198 SDL_Delay( 500);198 SDL_Delay(1000); 199 199 } 200 200
Note: See TracChangeset
for help on using the changeset viewer.