mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Ref T190, consolidate text messages before emitting text message
This commit is contained in:
@@ -801,8 +801,7 @@ namespace BlackCore
|
||||
{
|
||||
CTextMessage tm(cbvar_cast(cbvar)->fromFSD(msg), CCallsign(cbvar_cast(cbvar)->fromFSD(from)), CCallsign(cbvar_cast(cbvar)->fromFSD(to)));
|
||||
tm.setCurrentUtcTime();
|
||||
const CTextMessageList messages(tm);
|
||||
emit cbvar_cast(cbvar)->textMessagesReceived(messages);
|
||||
cbvar_cast(cbvar)->consolidateTextMessage(tm);
|
||||
}
|
||||
|
||||
void CNetworkVatlib::onRadioMessageReceived(VatSessionID, const char *from, int numFreq, int *freqList, const char *msg, void *cbvar)
|
||||
@@ -986,6 +985,25 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void CNetworkVatlib::consolidateTextMessage(const CTextMessage &textMessage)
|
||||
{
|
||||
if (textMessage.isSupervisorMessage())
|
||||
{
|
||||
emit this->textMessagesReceived(textMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_textMessagesToConsolidate.addConsolidatedTextMessage(textMessage);
|
||||
m_dsSendTextMessage.inputSignal(); // trigger
|
||||
}
|
||||
}
|
||||
|
||||
void CNetworkVatlib::emitConsolidatedTextMessages()
|
||||
{
|
||||
emit this->textMessagesReceived(m_textMessagesToConsolidate);
|
||||
m_textMessagesToConsolidate.clear();
|
||||
}
|
||||
|
||||
void CNetworkVatlib::onMetarReceived(VatSessionID, const char *data, void *cbvar)
|
||||
{
|
||||
auto *self = cbvar_cast(cbvar);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "blackmisc/network/server.h"
|
||||
#include "blackmisc/network/textmessagelist.h"
|
||||
#include "blackmisc/settingscache.h"
|
||||
#include "blackmisc/digestsignal.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <vatlib/vatlib.h>
|
||||
@@ -199,6 +200,13 @@ namespace BlackCore
|
||||
void terminate(); //!< \private
|
||||
|
||||
private:
|
||||
//! Consolidate text messages if we receive multiple messages which belong together
|
||||
//! \remark causes a slight delay
|
||||
void consolidateTextMessage(const BlackMisc::Network::CTextMessage &textMessage);
|
||||
|
||||
//! Send the consolidatedTextMessages
|
||||
void emitConsolidatedTextMessages();
|
||||
|
||||
//! Deletion policy for QScopedPointer
|
||||
struct VatlibQScopedPointerDeleter
|
||||
{
|
||||
@@ -220,6 +228,9 @@ namespace BlackCore
|
||||
BlackMisc::Aviation::CAircraftParts m_sentAircraftConfig; //!< aircraft parts sent
|
||||
BlackMisc::CTokenBucket m_tokenBucket; //!< used with aircraft parts messages
|
||||
|
||||
BlackMisc::CDigestSignal m_dsSendTextMessage { this, &CNetworkVatlib::emitConsolidatedTextMessages, 500, 10 };
|
||||
BlackMisc::Network::CTextMessageList m_textMessagesToConsolidate;
|
||||
|
||||
QTimer m_scheduledConfigUpdate;
|
||||
QTimer m_processingTimer;
|
||||
QTimer m_positionUpdateTimer;
|
||||
|
||||
Reference in New Issue
Block a user