public bool AddMessage(ref BinaryMessage t_msg) { bool messageAdded = false; int count = 0; byte[] t_buff = t_msg.GetMessageDataWithLen(); int i = m_endPos; int finIndex = GetNextValidIndex(m_endPos, t_msg.GetMessageLen_wLen()); if (finIndex < m_endPos) { for (; i < m_bufferSize; i++) { m_buffer[i] = t_buff[count]; count++; } i = GetNextValidIndex(i); for (; i < finIndex; i = GetNextValidIndex(i)) { m_buffer[i] = t_buff[count]; count++; } } else { for (; i < finIndex; i = GetNextValidIndex(i)) { m_buffer[i] = t_buff[count]; count++; } } m_endPos = GetNextValidIndex(m_endPos, t_msg.GetMessageLen_wLen()); messageAdded = true; return messageAdded; }