Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 28, 2005, 5:49:48 PM (19 years ago)
Author:
patrick
Message:

network: changed the synchronizeable interface, since the data synchronizeables, more debug output

File:
1 edited

Legend:

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

    r5802 r5804  
    5555{
    5656  this->init();
    57   this->networkSocket = new NetworkSocket( address, 9999 );
    58    // this->networkSocket->connectToServer(address, 88);
     57  this->networkSocket = new NetworkSocket(address);
    5958  this->networkProtocol = new NetworkProtocol();
    6059  this->synchronizeables = &sync;
     
    6362
    6463
    65 NetworkStream::NetworkStream(Synchronizeable& sync, int port, NodeType type)
     64NetworkStream::NetworkStream(Synchronizeable& sync, unsigned int port, NodeType type)
    6665  : DataStream()
    6766{
    6867  this->init();
    69   this->networkSocket = new NetworkSocket(/* address, type */);
    70   this->networkSocket->listen(9999);
     68  this->networkSocket = new NetworkSocket();
     69  this->networkSocket->listen(port);
    7170  this->networkProtocol = new NetworkProtocol();
    7271  this->synchronizeables = &sync;
     
    9493void NetworkStream::processData()
    9594{
    96 
    97 
    9895  int ret = 0;
    9996
    10097  /* DOWNSTREAM */
    101 
    102   PRINT(0)("\n\n");
     98  printf("\nSynchronizeable: %s\n", this->synchronizeables->getName());
    10399  PRINT(0)("============= DOWNSTREAM:===============\n");
    104100  /* first of all read the synchronizeable's data: */
     
    121117
    122118  /* UPSTREAM */
    123 
    124119  ret = 0;
    125120  PRINT(0)("============== UPSTREAM:================\n");
     
    128123  /* error checking: data read? */
    129124  printf("NetworkSocket: received %i bytes\n", ret);
    130   if( ret != PACKAGE_SIZE + sizeof(Header)) { PRINTF(0)("Error while reading data from the NetworkSocket. Skipping further work\n");}
     125  if( ret != 11 /*PACKAGE_SIZE + sizeof(Header)*/) { PRINTF(0)("Error while reading data from the NetworkSocket. Skipping further work\n");}
    131126  else
    132127  {
     
    135130
    136131    /* extract Header */
    137     this->networkProtocol->extractHeader((byte*) upBuffer , ret);
     132    Header header = this->networkProtocol->extractHeader((byte*) upBuffer , ret);
    138133
    139134    /* now pass the data to the sync object */
    140     this->synchronizeables->writeBytes((byte*)upBuffer, ret);
     135    this->synchronizeables->writeBytes((byte*)upBuffer, header.length);
    141136  }
    142137
Note: See TracChangeset for help on using the changeset viewer.