diff --git a/reflector/Protocol.h b/reflector/Protocol.h index 415d98c..8dafe08 100644 --- a/reflector/Protocol.h +++ b/reflector/Protocol.h @@ -73,6 +73,7 @@ public: // get const CCallsign &GetReflectorCallsign(void)const { return m_ReflectorCallsign; } + uint16_t GetPort(void) const { return m_Port; } // task void Thread(void); @@ -135,7 +136,7 @@ protected: CCallsign m_ReflectorCallsign; // data - uint8_t m_Port; + uint16_t m_Port; // debug CTimer m_DebugTimer; }; diff --git a/reflector/Reflector.cpp b/reflector/Reflector.cpp index 23637a1..0cc04f0 100644 --- a/reflector/Reflector.cpp +++ b/reflector/Reflector.cpp @@ -275,16 +275,19 @@ void CReflector::RouterThread(const char ThisModule) m_Protocols.Lock(); for ( auto it=m_Protocols.begin(); it!=m_Protocols.end(); it++ ) { + // make a copy! after the Push(tmp), tmp will be nullptr! + auto tmp = packet; + // if packet is header, update RPT2 according to protocol - if ( packet->IsDvHeader() ) + if ( tmp->IsDvHeader() ) { // get our callsign CCallsign csRPT = (*it)->GetReflectorCallsign(); csRPT.SetCSModule(ThisModule); - (dynamic_cast(packet.get()))->SetRpt2Callsign(csRPT); + std::cout << "For protocol on port " << (*it)->GetPort() << ", Rpt2Callsign is " << csRPT << std::endl; + (dynamic_cast(tmp.get()))->SetRpt2Callsign(csRPT); } - // make a copy! after the Push(tmp), tmp will be nullptr! - auto tmp = packet; + (*it)->Push(tmp); } m_Protocols.Unlock();