Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6139 in orxonox.OLD for trunk/src/lib/network/network_protocol.cc


Ignore:
Timestamp:
Dec 16, 2005, 6:45:32 PM (18 years ago)
Author:
patrick
Message:

trunk: merged branche network with trunk using command: svn merge -r5999:HEAD, conflicts resolved in favor of the trunk bla

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/network/network_protocol.cc

    r5822 r6139  
    5757    * @arg bufferLength: the length of the internal buffer
    5858    * @arg source: reference to the source Synchronizeable object
    59     * @arg remoteID: id number of the remote Synchronizeable object
    6059    * @return: the new data length with header (the header data is included into byte* data)
    6160    *          -1 if there isn't enough space in the buffer for the header
    6261*/
    63 int NetworkProtocol::createHeader(byte* data, int length, int bufferLength, const Synchronizeable& source, unsigned int remoteID)
     62int NetworkProtocol::createHeader(byte* data, int length, int bufferLength, const Synchronizeable& source)
    6463{
    65   printf("NetworkProtocol: create header length = %i, bufferLength = %i\n", length, bufferLength);
     64  PRINTF(5)("create header length = %i, bufferLength = %i\n", length, bufferLength);
    6665  //If there isn't enough space for the header return -1
    6766  if (length + this->headerLength > bufferLength)
    6867    return -1;
    6968
    70 //   for(int i = 0; i < length; i++)
    71 //     printf("send byte[%i]=%u\n", i, data[i]);
    7269
    73 
    74   //Create space for the header
     70  // FIXME: without move Create space for the header
    7571  for( int i = length - 1; i >= 0; i--)
    7672    data[i + this->headerLength] = data[i];
    7773
    7874  //Now create the header
    79   /* protocol identifier */
    80   data[0] = 255;
    81   /* version number */
    82   data[1] = 0;
    8375  /* sender ID: FIXME: there will be a better ID (for example unique:D)*/
    84   data[2] = (byte)source.getClassID();
    85   /* receiver ID */
    86   data[3] = remoteID;
     76  data[0] = (byte)(source.getUniqueID());
    8777  /* data length*/
    88   data[4] = length;
     78  data[1] = length;
    8979
    9080
     
    10090Header NetworkProtocol::extractHeader(byte* data, int length)
    10191{
    102   PRINTF(0)("extract Header\n");
     92  PRINTF(5)("extract Header\n");
    10393  //Test if received data can contain a header
    10494  if (length < headerLength)
    10595  {
    106     PRINTF(0)("Received data is to short; it can't contain a header!");
     96    PRINTF(1)("Received data is to short; it can't contain a header!\n");
    10797    Header h;
    108     h.protocol = 0;
     98    h.length = 0;
    10999    return h;
    110100  }
     
    114104  //&h = data;
    115105
    116   h.protocol = data[0];
    117   /* version number */
    118   h.version = data[1];
    119   /* sender ID: FIXME: there will be a better ID (for example unique:D)*/
    120   h.senderID = data[2];
    121   /* receiver ID */
    122   h.receiverID = data[3];
     106  /* unique ID */
     107  h.synchronizeableID = data[0];
    123108  /* data length*/
    124   h.length = data[4];
     109  h.length = data[1];
    125110
    126 
    127 //   for(int i = 0; i < length; i++)
    128 //     printf("recS byte[%i]=%u\n", i, data[i]);
    129 
    130   //Remove header
    131 //   for (int i = headerLength; i < length; i++)
    132 //     data[i - headerLength] = data[i];
    133111
    134112  return h;
Note: See TracChangeset for help on using the changeset viewer.