Skip to content

Commit 9cb07a9

Browse files
committed
Fixed the issue with TARGET_ALL
1 parent 92df8d7 commit 9cb07a9

File tree

10 files changed

+52
-52
lines changed

10 files changed

+52
-52
lines changed

framework/areg/component/NEService.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ namespace NEService
358358
* \brief NEService::TARGET_ALL
359359
* The undefined (all) target ID
360360
**/
361-
constexpr ITEM_ID TARGET_ALL { static_cast<ITEM_ID>(NECommon::eCookies::CookieInvalid) };
361+
constexpr ITEM_ID TARGET_ALL { static_cast<ITEM_ID>(NEService::COOKIE_ANY) };
362362
/**
363363
* \brief NEService::SOURCE_UNKNOWN
364364
* The unknown source ID

framework/areg/logging/NELogging.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ namespace NELogging
517517
/**
518518
* \brief Creates a message to query instances connected to the service.
519519
* \param source The source ID that created the query message. Should be the ID of the log observer or the ID of the log collector service.
520-
* \param target The target ID to send the message. The target is either concrete target or NEService::COOKIE_ANY if message targets all clients.
520+
* \param target The target ID to send the message. The target is either concrete target or NEService::TARGET_ALL if message targets all clients.
521521
* \return Returns generated message ready to forward to target client(s) via log collector service.
522522
**/
523523
AREG_API RemoteMessage messageQueryInstances(const ITEM_ID& source, const ITEM_ID& target);
@@ -532,7 +532,7 @@ namespace NELogging
532532
* \param source The ID of the source that generated the message.
533533
* The source should be either log observer or NEService::COOKIE_LOGGER.
534534
* \param target The ID of the target to send the message.
535-
* If the ID is NEService::COOKIE_ANY, the message is sent to all connected clients.
535+
* If the ID is NEService::TARGET_ALL, the message is sent to all connected clients.
536536
* \return Returns generated message ready to send from indicated source to the target.
537537
**/
538538
AREG_API RemoteMessage messageQueryScopes(const ITEM_ID& source, const ITEM_ID& target);
@@ -554,7 +554,7 @@ namespace NELogging
554554
* \param source The source ID that generated the message. It should be either ID of the log observer application
555555
* or the ID of the log collector service.
556556
* \param target The target ID to receive the message. This target can be either concrete connected client
557-
* or can be NEService::COOKIE_ANY if should be forwarded to all connected clients.
557+
* or can be NEService::TARGET_ALL if should be forwarded to all connected clients.
558558
* \return Returns generated message ready to send to client(s) via log collector service.
559559
**/
560560
AREG_API RemoteMessage messageSaveConfiguration(const ITEM_ID & source, const ITEM_ID & target);

framework/areglogger/client/LogObserverBase.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ class LOGGER_API LogObserverBase
263263
* \brief Requests to update the priority of the logging message to receive.
264264
* The indicated scopes can be scope group.
265265
* \param target The valid cookie ID of the target to update the log message priority.
266-
* This value cannot be NEService::TARGET_ALL (or 0).
266+
* This value cannot be NEService::TARGET_ALL (or 0xFF).
267267
* \param scopes The list of scopes of scope group to update the priority.
268268
* The scope group should end with '*'. For example 'areg_base_*'.
269269
* In this case the ID of the scope can be 0.
@@ -276,7 +276,7 @@ class LOGGER_API LogObserverBase
276276
* \brief Requests to save current configuration of the specified target. This is normally called when update the log priority of the instance,
277277
* so that on next start the application logs message of the scopes and priorities currently set.
278278
* \param target The cookie ID of the target instance to save the configuration.
279-
* If the target is NEService::TARGET_ALL (or 0), the request is sent to all connected instances.
279+
* If the target is NEService::TARGET_ALL (or 0xFF), the request is sent to all connected instances.
280280
* Otherwise, should be indicated the valid cookie ID of the connected log instance.
281281
* \return Returns true if processed with success. Otherwise, returns false.
282282
**/

framework/areglogger/client/private/LoggerClient.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,37 +187,37 @@ bool LoggerClient::requestConnectedInstances(void)
187187
return result;
188188
}
189189

190-
bool LoggerClient::requestScopes(const ITEM_ID& target /*= NEService::COOKIE_ANY*/)
190+
bool LoggerClient::requestScopes(const ITEM_ID& target /*= NEService::TARGET_ALL*/)
191191
{
192192
bool result{ false };
193193
Lock lock(mLock);
194-
if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::COOKIE_UNKNOWN))
194+
if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::TARGET_UNKNOWN))
195195
{
196-
result = sendMessage(NELogging::messageQueryScopes(mChannel.getCookie(), target == NEService::COOKIE_ANY ? LoggerClient::TargetID : target));
196+
result = sendMessage(NELogging::messageQueryScopes(mChannel.getCookie(), target == NEService::TARGET_ALL ? LoggerClient::TargetID : target));
197197
}
198198

199199
return result;
200200
}
201201

202-
bool LoggerClient::requestChangeScopePrio(const NELogging::ScopeNames & scopes, const ITEM_ID& target /*= NEService::COOKIE_ANY*/)
202+
bool LoggerClient::requestChangeScopePrio(const NELogging::ScopeNames & scopes, const ITEM_ID& target /*= NEService::TARGET_ALL*/)
203203
{
204204
bool result{ false };
205205
Lock lock(mLock);
206-
if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::COOKIE_UNKNOWN))
206+
if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::TARGET_UNKNOWN))
207207
{
208-
result = sendMessage(NELogging::messageUpdateScopes(mChannel.getCookie(), target == NEService::COOKIE_ANY ? LoggerClient::TargetID : target, scopes));
208+
result = sendMessage(NELogging::messageUpdateScopes(mChannel.getCookie(), target == NEService::TARGET_ALL ? LoggerClient::TargetID : target, scopes));
209209
}
210210

211211
return result;
212212
}
213213

214-
bool LoggerClient::requestSaveConfiguration(const ITEM_ID& target /*= NEService::COOKIE_ANY*/)
214+
bool LoggerClient::requestSaveConfiguration(const ITEM_ID& target /*= NEService::TARGET_ALL*/)
215215
{
216216
bool result{ false };
217217
Lock lock(mLock);
218-
if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::COOKIE_UNKNOWN))
218+
if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::TARGET_UNKNOWN))
219219
{
220-
result = sendMessage(NELogging::messageSaveConfiguration(mChannel.getCookie(), target == NEService::COOKIE_ANY ? LoggerClient::TargetID : target));
220+
result = sendMessage(NELogging::messageSaveConfiguration(mChannel.getCookie(), target == NEService::TARGET_ALL ? LoggerClient::TargetID : target));
221221
}
222222

223223
return result;

framework/areglogger/client/private/LoggerClient.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,37 +180,37 @@ class LoggerClient : public ServiceClientConnectionBase
180180
/**
181181
* \brief Generates and sends the message to query list of scopes.
182182
* The message is sent either to certain target or to all connected clients
183-
* if the target is NEService::COOKIE_ANY.
183+
* if the target is NEService::TARGET_ALL.
184184
* \param target The ID of the target to send the message.
185-
* The message is sent to all clients if the target is NEService::COOKIE_ANY.
185+
* The message is sent to all clients if the target is NEService::TARGET_ALL.
186186
* \return Returns true if processed the request with success. Otherwise, returns false.
187187
**/
188-
bool requestScopes(const ITEM_ID& target = NEService::COOKIE_ANY);
188+
bool requestScopes(const ITEM_ID& target = NEService::TARGET_ALL);
189189

190190
/**
191191
* \brief Generates and sends the message to update the scope priority.
192192
* The message is sent either to certain target or to all connected clients
193-
* if the target is NEService::COOKIE_ANY.
193+
* if the target is NEService::TARGET_ALL.
194194
* \param scopes The list of scopes or scope group to update the log message priority.
195195
* Each entry contains scope name, scope ID and the scope message priority.
196196
* The ID can be 0 if the name refers to a scope group.
197197
* \param target The ID of the target to send the message.
198-
* The message is sent to all clients if the target is NEService::COOKIE_ANY.
198+
* The message is sent to all clients if the target is NEService::TARGET_ALL.
199199
* \return Returns true if processed the request with success. Otherwise, returns false.
200200
**/
201-
bool requestChangeScopePrio(const NELogging::ScopeNames& scopes, const ITEM_ID& target = NEService::COOKIE_ANY);
201+
bool requestChangeScopePrio(const NELogging::ScopeNames& scopes, const ITEM_ID& target = NEService::TARGET_ALL);
202202

203203
/**
204204
* \brief Generates and sends the message to request to save configuration current state,
205205
* so that on the next start the application starts with the configuration state.
206206
* Normally, this is used when change scope message priority.
207207
* The message is sent either to certain target or to all connected clients
208-
* if the target is NEService::COOKIE_ANY.
208+
* if the target is NEService::TARGET_ALL.
209209
* \param target The ID of the target to send the message.
210-
* The message is sent to all clients if the target is NEService::COOKIE_ANY.
210+
* The message is sent to all clients if the target is NEService::TARGET_ALL.
211211
* \return Returns true if processed the request with success. Otherwise, returns false.
212212
**/
213-
bool requestSaveConfiguration(const ITEM_ID & target = NEService::COOKIE_ANY);
213+
bool requestSaveConfiguration(const ITEM_ID & target = NEService::TARGET_ALL);
214214

215215
/**
216216
* \brief Creates of opens the database for the logging. If specified path is null or empty,

framework/logcollector/app/LogCollector.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ class LogCollector : public ServiceApplicationBase
313313
* \param optScope The option entry that contains scope priority update instruction.
314314
* If the command contains a list of scopes to update, the should be split by ';'.
315315
* \param msgList On output it contains a list a messages to send to the targets.
316-
* If a message is referred to all connected clients, the target is NEService::COOKIE_ANY.
316+
* If a message is referred to all connected clients, the target is NEService::TARGET_ALL.
317317
**/
318318
static void _createScopeMessage(const OptionParser::sOption& optScope, TEArrayList<RemoteMessage> & OUT msgList);
319319

framework/logcollector/service/private/LogCollectorMessageProcessor.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ void LogCollectorMessageProcessor::queryConnectedInstances(const RemoteMessage &
4646
}
4747
}
4848

49-
void LogCollectorMessageProcessor::notifyConnectedInstances(const NEService::MapInstances& instances, const ITEM_ID& target /*= NEService::COOKIE_ANY*/) const
49+
void LogCollectorMessageProcessor::notifyConnectedInstances(const NEService::MapInstances& instances, const ITEM_ID& target /*= NEService::TARGET_ALL*/) const
5050
{
5151
const auto& observers{ mLoggerService.getObservers() };
5252
if (observers.isEmpty())
5353
return;
5454

5555
RemoteMessage msgInstances;
56-
ASSERT((target == NEService::COOKIE_ANY) || (instances.contains(target) && isLogObserver(instances.getAt(target).ciSource)));
56+
ASSERT((target == NEService::TARGET_ALL) || (instances.contains(target) && isLogObserver(instances.getAt(target).ciSource)));
5757

5858
if (msgInstances.initMessage(NERemoteService::getMessageNotifyInstances().rbHeader) != nullptr)
5959
{
@@ -77,7 +77,7 @@ void LogCollectorMessageProcessor::notifyConnectedInstances(const NEService::Map
7777
msgInstances.moveToEnd();
7878
}
7979

80-
if (target == NEService::COOKIE_ANY)
80+
if (target == NEService::TARGET_ALL)
8181
{
8282
for (const auto& observer : observers.getData())
8383
{
@@ -105,7 +105,7 @@ void LogCollectorMessageProcessor::notifyDisconnectedInstances(const TEArrayList
105105
{
106106
msgInstances << NERemoteService::eRemoteConnection::RemoteDisconnected;
107107
msgInstances << listIds;
108-
if (target == NEService::COOKIE_ANY)
108+
if (target == NEService::TARGET_ALL)
109109
{
110110
for (const auto& observer : observers.getData())
111111
{
@@ -156,7 +156,7 @@ void LogCollectorMessageProcessor::saveLogSourceConfiguration(const RemoteMessag
156156

157157
ITEM_ID target{ NEService::COOKIE_UNKNOWN };
158158
msgReceived >> target;
159-
if ((target == NEService::COOKIE_ANY) || (target == NEService::COOKIE_LOGGER))
159+
if ((target == NEService::TARGET_ALL) || (target == NEService::COOKIE_LOGGER))
160160
{
161161
const NEService::MapInstances& instances{ mLoggerService.getInstances() };
162162
for (const auto& entry : instances.getData())
@@ -212,7 +212,7 @@ void LogCollectorMessageProcessor::processNextSaveConfig(void)
212212

213213
void LogCollectorMessageProcessor::clientDisconnected(const ITEM_ID& cookie)
214214
{
215-
if ((cookie > NEService::COOKIE_ANY) && (mPendingSave == cookie))
215+
if ((cookie > NEService::TARGET_ALL) && (mPendingSave == cookie))
216216
{
217217
processNextSaveConfig();
218218
}
@@ -254,7 +254,7 @@ inline void LogCollectorMessageProcessor::_forwardMessageToLogSources(const Remo
254254
return;
255255

256256
ITEM_ID source{ msgReceived.getSource() };
257-
ITEM_ID target{ msgReceived.getTarget() != NEService::COOKIE_LOGGER ? msgReceived.getTarget() : NEService::COOKIE_ANY };
257+
ITEM_ID target{ msgReceived.getTarget() != NEService::COOKIE_LOGGER ? msgReceived.getTarget() : NEService::TARGET_ALL };
258258

259259
auto srcPos = source != NEService::COOKIE_LOGGER ? instances.find(source) : instances.invalidPosition();
260260
if ((source == NEService::COOKIE_LOGGER) || (instances.isValidPosition(srcPos) && isLogObserver(instances.valueAtPosition(srcPos).ciSource)))
@@ -264,7 +264,7 @@ inline void LogCollectorMessageProcessor::_forwardMessageToLogSources(const Remo
264264
{
265265
mLoggerService.sendMessage(msgReceived);
266266
}
267-
else if (target == NEService::COOKIE_ANY)
267+
else if (target == NEService::TARGET_ALL)
268268
{
269269
for (const auto& instance : instances.getData())
270270
{
@@ -285,7 +285,7 @@ inline void LogCollectorMessageProcessor::_forwardMessageToObservers(const Remot
285285
return;
286286

287287
ITEM_ID source{ msgReceived.getSource() };
288-
ITEM_ID target{ msgReceived.getTarget() != NEService::COOKIE_LOGGER ? msgReceived.getTarget() : NEService::COOKIE_ANY };
288+
ITEM_ID target{ msgReceived.getTarget() != NEService::COOKIE_LOGGER ? msgReceived.getTarget() : NEService::TARGET_ALL };
289289
const NEService::MapInstances& instances = mLoggerService.getInstances();
290290

291291
auto srcPos = instances.find(source);
@@ -296,7 +296,7 @@ inline void LogCollectorMessageProcessor::_forwardMessageToObservers(const Remot
296296
{
297297
mLoggerService.sendMessage(msgReceived);
298298
}
299-
else if (target == NEService::COOKIE_ANY)
299+
else if (target == NEService::TARGET_ALL)
300300
{
301301
for (const auto& observer : observers.getData())
302302
{

framework/logcollector/service/private/LogCollectorMessageProcessor.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,25 @@ class LogCollectorMessageProcessor
6666

6767
/**
6868
* \brief Creates a communication message with the information of connected instances
69-
* and sends the notification to the specified observer target. If target is NEService::COOKIE_ANY
69+
* and sends the notification to the specified observer target. If target is NEService::TARGET_ALL
7070
* the notification is sent to all connected observers. Otherwise, it send to
7171
* the specified exact target.
7272
* \param instances The list of connected instances to include in the notification message.
73-
* \param target The ID of the target to send the message. If target is NEService::COOKIE_ANY,
73+
* \param target The ID of the target to send the message. If target is NEService::TARGET_ALL,
7474
* the notification message is sent to all observers. Otherwise, it is sent to the exact target.
7575
**/
76-
void notifyConnectedInstances(const NEService::MapInstances& instances, const ITEM_ID & target = NEService::COOKIE_ANY) const;
76+
void notifyConnectedInstances(const NEService::MapInstances& instances, const ITEM_ID & target = NEService::TARGET_ALL) const;
7777

7878
/**
7979
* \brief Creates a communication message with the IDs of disconnected instances
80-
* and sends the notification to the specified observer target. If target is NEService::COOKIE_ANY
80+
* and sends the notification to the specified observer target. If target is NEService::TARGET_ALL
8181
* the notification is sent to all connected observers. Otherwise, it send to
8282
* the specified exact target.
8383
* \param listIds The list of IDs of disconnected instances to include in the notification message.
84-
* \param target The ID of the target to send the message. If target is NEService::COOKIE_ANY,
84+
* \param target The ID of the target to send the message. If target is NEService::TARGET_ALL,
8585
* the notification message is sent to all observers. Otherwise, it is sent to the exact target.
8686
**/
87-
void notifyDisconnectedInstances(const TEArrayList<ITEM_ID> & listIds, const ITEM_ID& target = NEService::COOKIE_ANY) const;
87+
void notifyDisconnectedInstances(const TEArrayList<ITEM_ID> & listIds, const ITEM_ID& target = NEService::TARGET_ALL) const;
8888

8989
/**
9090
* \brief Called when a connected instance of application requests to register scopes.
@@ -179,14 +179,14 @@ class LogCollectorMessageProcessor
179179

180180
/**
181181
* \brief Forwards specified message to the log sources, i.e. clients.
182-
* If the target in the remote message is NEService::COOKIE_ANY, the message is sent to all clients.
182+
* If the target in the remote message is NEService::TARGET_ALL, the message is sent to all clients.
183183
* \param msgReceived The remote message received from observer or generated by the Log Collector.
184184
**/
185185
inline void _forwardMessageToLogSources(const RemoteMessage& msgReceived) const;
186186

187187
/**
188188
* \brief Forwards specified message to the log observer.
189-
* If the target in the remote message is NEService::COOKIE_ANY, the message is sent to all observers.
189+
* If the target in the remote message is NEService::TARGET_ALL, the message is sent to all observers.
190190
* \param msgReceived The remote message received from a client.
191191
**/
192192
inline void _forwardMessageToObservers(const RemoteMessage& msgReceived) const;

framework/logcollector/service/private/LogCollectorServerService.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void LogCollectorServerService::addInstance(const ITEM_ID& cookie, const NEServi
5555
, instance.ciLocation.c_str());
5656
NELogging::logAnyMessageLocal(logMsgHello);
5757

58-
mLoggerProcessor.notifyConnectedInstances(getInstances(), NEService::COOKIE_ANY);
58+
mLoggerProcessor.notifyConnectedInstances(getInstances(), NEService::TARGET_ALL);
5959
}
6060
else if (LogCollectorMessageProcessor::isLogObserver(instance.ciSource))
6161
{
@@ -86,7 +86,7 @@ void LogCollectorServerService::removeInstance(const ITEM_ID & cookie)
8686
NELogging::logAnyMessageLocal(logMsgBye);
8787

8888
listIds.add(instance.ciCookie);
89-
mLoggerProcessor.notifyDisconnectedInstances(listIds, NEService::COOKIE_ANY);
89+
mLoggerProcessor.notifyDisconnectedInstances(listIds, NEService::TARGET_ALL);
9090
}
9191
else if (LogCollectorMessageProcessor::isLogObserver(instance.ciSource))
9292
{
@@ -118,7 +118,7 @@ void LogCollectorServerService::removeAllInstances(void)
118118

119119
if (listIds.isEmpty() == false)
120120
{
121-
mLoggerProcessor.notifyDisconnectedInstances(listIds, NEService::COOKIE_ANY);
121+
mLoggerProcessor.notifyDisconnectedInstances(listIds, NEService::TARGET_ALL);
122122
}
123123
}
124124

0 commit comments

Comments
 (0)