Changeset 6115 in orxonox.OLD for branches/network
- Timestamp:
- Dec 14, 2005, 10:50:33 PM (19 years ago)
- Location:
- branches/network/src/lib/network
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/handshake.cc
r6090 r6115 22 22 #include "handshake.h" 23 23 24 Handshake::Handshake( bool server, int clientId )24 Handshake::Handshake( bool server, int clientId, int entityManagerId ) 25 25 { 26 26 /* set the class id for the base object */ 27 27 this->setClassID(CL_HANDSHAKE, "Handshake"); 28 28 29 if ( clientId > 255 ) 30 { 31 PRINTF(1)("clientId is too big for type byte (%d)! connection to client %d will not work!", clientId, clientId); 32 } 33 34 if ( entityManagerId > 255 ) 35 { 36 PRINTF(1)("entityManagerId is too big for type byte (%d)! connection to client %d will not work!", entityManagerId, clientId); 37 } 38 29 39 this->setIsServer(server); 30 40 this->clientId = clientId; 41 this->entityManagerId = entityManagerId; 31 42 this->state = 0; 32 43 this->isOk = false; … … 88 99 if ( !isServer() && hasState( HS_RECVD_VER ) && !hasState( HS_RECVD_HID ) ) 89 100 { 90 if ( length != 1)101 if ( length != 2 ) 91 102 { 92 103 PRINTF(0)("hostID packet has wrong size %d instead of %d\n", length, 1); … … 99 110 this->isOk = true; 100 111 this->newHostId = data[0]; 112 this->newEntityManagerId = data[1]; 101 113 102 114 if ( newHostId == 0 ) … … 156 168 if ( isServer() && hasState( HS_RECVD_VER) && hasState( HS_SENT_VER ) && !hasState( HS_SENT_HID ) ) 157 169 { 158 if ( maxLength < 4)170 if ( maxLength < 2 ) 159 171 { 160 172 PRINTF(0)("buffer too small for ID"); … … 177 189 //memcpy(data, &clientId, 4); 178 190 data[0] = (byte)clientId; 191 data[1] = (byte)entityManagerId; 179 192 } 180 193 *reciever = clientId; 181 return 1;194 return 2; 182 195 } 183 196 -
branches/network/src/lib/network/handshake.h
r6090 r6115 34 34 { 35 35 public: 36 Handshake(bool server, int clientId = 0 );36 Handshake(bool server, int clientId = 0, int entityManagerId = 0); 37 37 inline bool completed(){ return hasState( HS_COMPLETED ); } 38 38 inline bool ok(){ return isOk; } … … 49 49 int state; 50 50 int clientId; 51 int entityManagerId; 51 52 int newHostId; 53 int newEntityManagerId; 52 54 bool isOk; 53 55 -
branches/network/src/lib/network/network_socket.cc
r6062 r6115 51 51 this->tcpSocket = sock; 52 52 53 SDL_CreateThread(thread_read, (void*)this);54 SDL_CreateThread(thread_write, (void*)this);53 readThread = SDL_CreateThread(thread_read, (void*)this); 54 writeThread = SDL_CreateThread(thread_write, (void*)this); 55 55 } 56 56 … … 63 63 incomingBufferLength = 0; 64 64 outgoingBufferLength = 0; 65 66 readThread = NULL; 67 writeThread = NULL; 65 68 66 69 … … 129 132 } 130 133 131 SDL_CreateThread(thread_read, (void*)this);132 SDL_CreateThread(thread_write, (void*)this);134 readThread = SDL_CreateThread(thread_read, (void*)this); 135 writeThread = SDL_CreateThread(thread_write, (void*)this); 133 136 } 134 137 … … 310 313 if ( !self->thread_write_running ) 311 314 { 315 //delete self; 312 316 SDL_mutexV(self->threadTerminationMutex); 313 317 } … … 378 382 if ( !self->thread_read_running ) 379 383 { 384 //delete self; 380 385 SDL_mutexV(self->threadTerminationMutex); 381 386 } -
branches/network/src/lib/network/network_socket.h
r6039 r6115 67 67 bool thread_read_running; 68 68 bool thread_write_running; 69 70 SDL_Thread* readThread; 71 SDL_Thread* writeThread; 72 69 73 #ifdef _USE_OUTGOING_BUFFER 70 74 static int thread_write(void * data);
Note: See TracChangeset
for help on using the changeset viewer.