@@ -51,10 +51,11 @@ namespace Transports
51
51
{
52
52
public:
53
53
Listener (Tasks::Task& task, UDPSocket& sock, LimitedComms* lcomms,
54
- float contact_timeout, bool trace = false ):
54
+ float contact_timeout, bool force = false , bool trace = false ):
55
55
m_task (task),
56
56
m_sock (sock),
57
57
m_trace (trace),
58
+ force_send (force),
58
59
m_contacts(contact_timeout),
59
60
m_lcomms(lcomms)
60
61
{ }
@@ -83,6 +84,14 @@ namespace Transports
83
84
m_contacts_lock.unlock ();
84
85
}
85
86
87
+ void
88
+ addContact (unsigned id)
89
+ {
90
+ m_contacts_lock.lockWrite ();
91
+ m_contacts.addContact (id, Address::Any);
92
+ m_contacts_lock.unlock ();
93
+ }
94
+
86
95
private:
87
96
// Buffer capacity.
88
97
static const int c_bfr_size = 65535 ;
@@ -94,6 +103,8 @@ namespace Transports
94
103
UDPSocket& m_sock;
95
104
// True to print incoming messages.
96
105
bool m_trace;
106
+ // Flag to force sending messages.
107
+ bool force_send;
97
108
// Table of contacts.
98
109
ContactTable m_contacts;
99
110
// Lock to serialize access to m_contacts.
@@ -133,10 +144,13 @@ namespace Transports
133
144
}
134
145
135
146
m_contacts_lock.lockWrite ();
136
- m_contacts.update (msg->getSource (), addr);
147
+ bool onTable = m_contacts.update (msg->getSource (), addr);
137
148
m_contacts_lock.unlock ();
138
149
139
- m_task.dispatch (msg, DF_KEEP_TIME | DF_KEEP_SRC_EID);
150
+ if (force_send)
151
+ m_task.dispatch (msg, DF_KEEP_TIME | DF_KEEP_SRC_EID);
152
+ else if (onTable)
153
+ m_task.dispatch (msg, DF_KEEP_TIME | DF_KEEP_SRC_EID);
140
154
141
155
if (m_trace)
142
156
DUNE_MSG (m_task.getName (), " incoming: " + std::string (msg->getName ()));
0 commit comments