Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6115 in orxonox.OLD for branches


Ignore:
Timestamp:
Dec 14, 2005, 10:50:33 PM (19 years ago)
Author:
rennerc
Message:

handshake now sends NetworkGameManagerId

Location:
branches/network/src/lib/network
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/handshake.cc

    r6090 r6115  
    2222#include "handshake.h"
    2323
    24 Handshake::Handshake( bool server, int clientId )
     24Handshake::Handshake( bool server, int clientId, int entityManagerId )
    2525{
    2626  /* set the class id for the base object */
    2727  this->setClassID(CL_HANDSHAKE, "Handshake");
    2828
     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
    2939  this->setIsServer(server);
    3040  this->clientId = clientId;
     41  this->entityManagerId = entityManagerId;
    3142  this->state = 0;
    3243  this->isOk = false;
     
    8899  if ( !isServer() && hasState( HS_RECVD_VER ) && !hasState( HS_RECVD_HID ) )
    89100  {
    90     if ( length != 1 )
     101    if ( length != 2 )
    91102    {
    92103      PRINTF(0)("hostID packet has wrong size %d instead of %d\n", length, 1);
     
    99110    this->isOk = true;
    100111    this->newHostId = data[0];
     112    this->newEntityManagerId = data[1];
    101113
    102114    if ( newHostId == 0 )
     
    156168  if ( isServer() && hasState( HS_RECVD_VER) && hasState( HS_SENT_VER ) && !hasState( HS_SENT_HID ) )
    157169  {
    158     if ( maxLength < 4 )
     170    if ( maxLength < 2 )
    159171    {
    160172      PRINTF(0)("buffer too small for ID");
     
    177189      //memcpy(data, &clientId, 4);
    178190      data[0] = (byte)clientId;
     191      data[1] = (byte)entityManagerId;
    179192    }
    180193    *reciever = clientId;
    181     return 1;
     194    return 2;
    182195  }
    183196
  • branches/network/src/lib/network/handshake.h

    r6090 r6115  
    3434{
    3535  public:
    36     Handshake(bool server, int clientId = 0);
     36    Handshake(bool server, int clientId = 0, int entityManagerId = 0);
    3737    inline bool       completed(){ return hasState( HS_COMPLETED ); }
    3838    inline bool       ok(){ return isOk; }
     
    4949    int               state;
    5050    int               clientId;
     51    int               entityManagerId;
    5152    int               newHostId;
     53    int               newEntityManagerId;
    5254    bool              isOk;
    5355
  • branches/network/src/lib/network/network_socket.cc

    r6062 r6115  
    5151  this->tcpSocket = sock;
    5252
    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);
    5555}
    5656
     
    6363  incomingBufferLength = 0;
    6464  outgoingBufferLength = 0;
     65
     66  readThread = NULL;
     67  writeThread = NULL;
    6568
    6669
     
    129132  }
    130133
    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);
    133136}
    134137
     
    310313  if ( !self->thread_write_running )
    311314  {
     315    //delete self;
    312316    SDL_mutexV(self->threadTerminationMutex);
    313317  }
     
    378382  if ( !self->thread_read_running )
    379383  {
     384    //delete self;
    380385    SDL_mutexV(self->threadTerminationMutex);
    381386  }
  • branches/network/src/lib/network/network_socket.h

    r6039 r6115  
    6767  bool thread_read_running;
    6868  bool thread_write_running;
     69
     70  SDL_Thread*            readThread;
     71  SDL_Thread*            writeThread;
     72
    6973#ifdef _USE_OUTGOING_BUFFER
    7074  static int thread_write(void * data);
Note: See TracChangeset for help on using the changeset viewer.