1
0
Fork 0

add documentation for the spec 1.0 stream format

This commit is contained in:
Kevin Matz 2023-05-15 11:23:49 -04:00
parent bf61bd9c3e
commit 31ec3ade78
1 changed files with 9 additions and 7 deletions

View File

@ -123,23 +123,25 @@ void Receiver::rxPacket(std::shared_ptr<bufferstream> buffer) const
/**
* @brief Receiver::rxPacketTCP
* @brief Receiver::rxPacketStream
* @param buffer
*
* This method is presented in \cite Spec10 Spec 1.0, but has been delared as legacy
* in favor SLIP framming.
*
* \note It may be necessary to later move the length check into the TCP receiver.
* in favor of SLIP framming. \see rxPacketSLIP
*/
void Receiver::rxPacketTCP(std::shared_ptr<bufferstream> buffer) const
void Receiver::rxPacketStream(std::shared_ptr<bufferstream> buffer) const
{
/// > \cite Spec10 In a stream-based protocol such as TCP, the stream should begin with
/// > an int32 giving the size of the first packet, followed by the contents of the
/// > first packet, followed by the size of the second packet, etc.
while (buffer->good()) {
uint32_t size;
size_t size = buffer->readType<int32_t>();
auto msg = std::make_shared<Message>();
*buffer >> size;
msg->iStream(buffer);
if (size != msg->streamSize())
buffer->setstate(std::ios::failbit);
if (!buffer->fail())
dispatch(msg);
}