#16 only read header once

pull/32/head
Geoffrey Merck 4 years ago
parent 8fea937062
commit c7734af8af

@ -34,7 +34,8 @@ m_type(GT_NONE),
m_buffer(nullptr),
m_length(0U),
m_address(destination),
m_inactivityTimer(1000U, 29U)
m_inactivityTimer(1000U, 29U),
m_id(0U)
{
m_inactivityTimer.start();
m_buffer = new unsigned char[bufferSize];
@ -117,7 +118,7 @@ bool CG2ProtocolHandler::setBuffer(unsigned char * buffer, int length)
CHeaderData* CG2ProtocolHandler::readHeader()
{
m_inactivityTimer.start();
if (m_type != GT_HEADER)
if (m_type != GT_HEADER || m_id != 0U)
return nullptr;
m_type = GT_NONE; // Header data has been consumed, reset our status
@ -130,6 +131,8 @@ CHeaderData* CG2ProtocolHandler::readHeader()
return nullptr;
}
m_id = header->getId();// remember the id so we do not read it duplicate
return header;
}
@ -148,6 +151,9 @@ CAMBEData* CG2ProtocolHandler::readAMBE()
return NULL;
}
if(data->isEnd())
m_id = 0U;
return data;
}

@ -63,6 +63,7 @@ private:
unsigned int m_length;
struct sockaddr_storage m_address;
CTimer m_inactivityTimer;
unsigned int m_id;
bool readPackets();
};

Loading…
Cancel
Save

Powered by TurnKey Linux.