Changeset 5741 in orxonox.OLD for branches/network/src/lib
- Timestamp:
- Nov 23, 2005, 4:15:09 PM (19 years ago)
- Location:
- branches/network/src/lib/network
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/network_stream.cc
r5738 r5741 19 19 */ 20 20 #define DEBUG_MODULE_NETWORK 21 #define PACKAGE_SIZE 821 #define PACKAGE_SIZE 256 22 22 23 23 #include "base_object.h" … … 43 43 /* initialize the references */ 44 44 this->networkSocket = new NetworkSocket(); 45 this->networkProtocol = new NetworkProtocol(); 45 46 this->synchronizeables = NULL; 46 47 this->connectionMonitor = new ConnectionMonitor(); … … 54 55 this->networkSocket = new NetworkSocket( address, 88 ); 55 56 // this->networkSocket->connectToServer(address, 88); 56 57 this->networkProtocol = new NetworkProtocol(); 57 58 this->synchronizeables = &sync; 59 this->connectionMonitor = new ConnectionMonitor(); 58 60 } 59 61 … … 64 66 this->init(); 65 67 this->networkSocket = new NetworkSocket(/* address, type */); 66 68 this->networkProtocol = new NetworkProtocol(); 67 69 this->synchronizeables = &sync; 70 this->connectionMonitor = new ConnectionMonitor(); 68 71 } 69 72 … … 91 94 92 95 int ret = 0; 96 97 /* DOWNSTREAM */ 98 99 /* first of all read the synchronizeable's data: */ 100 ret = this->synchronizeables->readBytes((byte*)downBuffer); 93 101 94 95 96 /* DOWNSTREAM */ 97 /* first of all read the synchronizeable's data: */ 102 /* send the received data to connectionMonitor */ 103 this->connectionMonitor->processPacket((byte*)downBuffer, PACKAGE_SIZE); 98 104 99 ret = this->synchronizeables->readBytes((byte*)downBuffer); 100 this->connectionMonitor->processPacket((byte*)downBuffer, PACKAGE_SIZE); 101 //this-> ->extractHeader(byte* data, int length); 105 this->networkProtocol->createHeader((byte*) downBuffer , PACKAGE_SIZE, 1024,*(this->synchronizeables),12); 106 102 107 /* pass the data to the network socket */ 103 108 ret = this->networkSocket->writeBytes((byte*)downBuffer, PACKAGE_SIZE); … … 105 110 if( ret == -1) { PRINTF(0)("Error in writing data to the NetworkSocket\n");} 106 111 112 113 114 /* UPSTREAM */ 107 115 108 /* UPSTREAM */ 109 /* first read 10bytes of data (debug) */ 116 ret = 0; 110 117 111 ret = 0;112 118 while(ret == 0) ret = this->networkSocket->readBlock((byte*)upBuffer,PACKAGE_SIZE); 113 119 /* error checking: data read? */ 114 120 if( ret != PACKAGE_SIZE) { PRINTF(0)("Error while reading data from the NetworkSocket\n");} 121 122 /* send the received data to connectionMonitor */ 123 this->connectionMonitor->processPacket((byte*)upBuffer, PACKAGE_SIZE); 124 125 /* extract Header */ 126 this->networkProtocol->extractHeader((byte*) upBuffer , PACKAGE_SIZE); 127 115 128 /* now pass the data to the sync object */ 116 117 this->synchronizeables->writeBytes((byte*)upBuffer, PACKAGE_SIZE); 118 119 120 129 this->synchronizeables->writeBytes((byte*)upBuffer[sizeof(Header)], PACKAGE_SIZE); 121 130 122 131 } 123 -
branches/network/src/lib/network/network_stream.h
r5728 r5741 12 12 class NetworkSocket; 13 13 class ConnectionMonitor; 14 class NetworkProtocol; 14 15 15 16 class NetworkStream : public DataStream … … 28 29 29 30 private: 30 //NetworkProtocol* networkProtocol;31 //NetworkSocket* networkSockets;32 ConnectionMonitor* connectionMonitor;33 // tList<Synchronizeable>* synchronizeables;34 Synchronizeable* synchronizeables;35 NetworkSocket* networkSocket;31 NetworkProtocol* networkProtocol; 32 //NetworkSocket* networkSockets; 33 ConnectionMonitor* connectionMonitor; 34 // tList<Synchronizeable>* synchronizeables; 35 Synchronizeable* synchronizeables; 36 NetworkSocket* networkSocket; 36 37 }; 37 38 #endif /* _NETWORK_STREAM */
Note: See TracChangeset
for help on using the changeset viewer.