diff --git a/G2ProtocolHandler.cpp b/G2ProtocolHandler.cpp index cbaf541..e73d918 100644 --- a/G2ProtocolHandler.cpp +++ b/G2ProtocolHandler.cpp @@ -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; } diff --git a/G2ProtocolHandler.h b/G2ProtocolHandler.h index edcf2b3..92b42a0 100644 --- a/G2ProtocolHandler.h +++ b/G2ProtocolHandler.h @@ -63,6 +63,7 @@ private: unsigned int m_length; struct sockaddr_storage m_address; CTimer m_inactivityTimer; + unsigned int m_id; bool readPackets(); };