Skip to content

Commit

Permalink
checking the event sequence of group topology
Browse files Browse the repository at this point in the history
  • Loading branch information
janbar committed Jan 3, 2020
1 parent c225661 commit 13e41d6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 20 additions & 2 deletions noson/src/zonegrouptopology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ ZoneGroupTopology::ZoneGroupTopology(const std::string& serviceHost, unsigned se
, m_eventCB(nullptr)
, m_msgCount(0)
, m_topologyKey(0)
, m_eventSEQ(0)
, m_zones(ZoneList())
, m_zonePlayers(ZonePlayerList())
{
Expand All @@ -69,6 +70,7 @@ ZoneGroupTopology::ZoneGroupTopology(const std::string& serviceHost, unsigned se
, m_eventCB(eventCB)
, m_msgCount(0)
, m_topologyKey(0)
, m_eventSEQ(0)
, m_zones(ZoneList())
, m_zonePlayers(ZonePlayerList())
{
Expand Down Expand Up @@ -105,8 +107,24 @@ void ZoneGroupTopology::HandleEventMessage(EventMessagePtr msg)
if (m_subscription.GetSID() == msg->subject[0] && msg->subject[2] == "PROPERTY")
{
DBG(DBG_DEBUG, "%s: %s SEQ=%s %s\n", __FUNCTION__, msg->subject[0].c_str(), msg->subject[1].c_str(), msg->subject[2].c_str());

// check for higher sequence
uint32_t seq = 0;
string_to_uint32(msg->subject[1].c_str(), &seq);
if (msg->subject[0] != m_eventSID)
{
m_eventSID = msg->subject[0];
}
else if (seq < m_eventSEQ)
{
DBG(DBG_DEBUG, "%s: %s SEQ=%u , discarding %u\n", __FUNCTION__, m_eventSID.c_str(), m_eventSEQ, seq);
return;
}
// tracking serial of the event
m_eventSEQ = seq;

std::vector<std::string>::const_iterator it = msg->subject.begin();
unsigned _key = m_topologyKey;
unsigned _oldKey = m_topologyKey;
while (it != msg->subject.end())
{
if (*it == "ZoneGroupState")
Expand All @@ -119,7 +137,7 @@ void ZoneGroupTopology::HandleEventMessage(EventMessagePtr msg)
++it;
}
// Event is signaled only on first or any change
if (m_msgCount && _key == m_topologyKey)
if (m_msgCount && _oldKey == m_topologyKey)
return;
// Signal
++m_msgCount;
Expand Down
2 changes: 2 additions & 0 deletions noson/src/zonegrouptopology.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ namespace NSROOT
EventCB m_eventCB;
unsigned m_msgCount;
unsigned m_topologyKey;
unsigned m_eventSEQ;
std::string m_eventSID;

Locked<ZoneList> m_zones;
Locked<ZonePlayerList> m_zonePlayers;
Expand Down

0 comments on commit 13e41d6

Please sign in to comment.