Changeset 5810 in orxonox.OLD for branches/network
- Timestamp:
- Nov 28, 2005, 10:20:08 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/network_stream.cc
r5809 r5810 122 122 /* first of all read the next Orxonox Network Header */ 123 123 124 switch( this->state)124 if( this->state == NET_REC_HEADER) 125 125 { 126 dataLength = this->networkSocket->readBlock((byte*)upBuffer, sizeof(Header)); 127 if( dataLength == sizeof(Header)) 128 { 129 this->packetHeader = this->networkProtocol->extractHeader((byte*) upBuffer , dataLength); 130 printf("NetworkStream::processData() - Got Header: Protocol %u, Version: %u, Sender: %u, Receiver: %u, Length: %u\n", 131 this->packetHeader.protocol, this->packetHeader.version, this->packetHeader.senderID, 132 this->packetHeader.receiverID, this->packetHeader.length); 133 /* FIXME: what if it was no this->packetHeader? catch? eg: the protocol identifier, receiver id*/ 126 134 127 case NET_REC_HEADER: 128 dataLength = this->networkSocket->readBlock((byte*)upBuffer, sizeof(Header)); 129 if( dataLength == sizeof(Header)) 130 { 131 this->packetHeader = this->networkProtocol->extractHeader((byte*) upBuffer , dataLength); 132 printf("NetworkStream::processData() - Got Header: Protocol %u, Version: %u, Sender: %u, Receiver: %u, Length: %u\n", 133 this->packetHeader.protocol, this->packetHeader.version, this->packetHeader.senderID, 134 this->packetHeader.receiverID, this->packetHeader.length); 135 /* FIXME: what if it was no this->packetHeader? catch? eg: the protocol identifier, receiver id*/ 135 this->state = NET_REC_DATA; 136 } 137 } 138 if( this->state == NET_REC_DATA) 139 { 140 /* now read the data */ 141 dataLength = this->networkSocket->readBlock((byte*)upBuffer, this->packetHeader.length); 142 /* check if the data is available and process it if so */ 143 if( dataLength == this->packetHeader.length) 144 { 145 printf("NetworkStream::processData() - Got Data: \n"); 146 /* send the received data to connectionMonitor */ 147 this->connectionMonitor->processPacket((byte*)upBuffer, this->packetHeader.length); 148 /* now pass the data to the sync object */ 149 this->synchronizeables->writeBytes((byte*)upBuffer, this->packetHeader.length); 136 150 137 this->state = NET_REC_DATA; 138 } 139 break; 140 141 case NET_REC_DATA: 142 /* now read the data */ 143 dataLength = this->networkSocket->readBlock((byte*)upBuffer, this->packetHeader.length); 144 /* check if the data is available and process it if so */ 145 if( dataLength == this->packetHeader.length) 146 { 147 printf("NetworkStream::processData() - Got Data: \n"); 148 /* send the received data to connectionMonitor */ 149 this->connectionMonitor->processPacket((byte*)upBuffer, this->packetHeader.length); 150 /* now pass the data to the sync object */ 151 this->synchronizeables->writeBytes((byte*)upBuffer, this->packetHeader.length); 152 153 this->state = NET_REC_HEADER; 154 } 155 break; 156 157 default: 158 break; 151 this->state = NET_REC_HEADER; 152 } 159 153 } 160 154
Note: See TracChangeset
for help on using the changeset viewer.