Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion framework/areg/component/NEService.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ namespace NEService
* \brief NEService::TARGET_ALL
* The undefined (all) target ID
**/
constexpr ITEM_ID TARGET_ALL { static_cast<ITEM_ID>(NECommon::eCookies::CookieInvalid) };
constexpr ITEM_ID TARGET_ALL { static_cast<ITEM_ID>(NEService::COOKIE_ANY) };
/**
* \brief NEService::SOURCE_UNKNOWN
* The unknown source ID
Expand Down
6 changes: 3 additions & 3 deletions framework/areg/logging/NELogging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ namespace NELogging
/**
* \brief Creates a message to query instances connected to the service.
* \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.
* \param target The target ID to send the message. The target is either concrete target or NEService::COOKIE_ANY if message targets all clients.
* \param target The target ID to send the message. The target is either concrete target or NEService::TARGET_ALL if message targets all clients.
* \return Returns generated message ready to forward to target client(s) via log collector service.
**/
AREG_API RemoteMessage messageQueryInstances(const ITEM_ID& source, const ITEM_ID& target);
Expand All @@ -532,7 +532,7 @@ namespace NELogging
* \param source The ID of the source that generated the message.
* The source should be either log observer or NEService::COOKIE_LOGGER.
* \param target The ID of the target to send the message.
* If the ID is NEService::COOKIE_ANY, the message is sent to all connected clients.
* If the ID is NEService::TARGET_ALL, the message is sent to all connected clients.
* \return Returns generated message ready to send from indicated source to the target.
**/
AREG_API RemoteMessage messageQueryScopes(const ITEM_ID& source, const ITEM_ID& target);
Expand All @@ -554,7 +554,7 @@ namespace NELogging
* \param source The source ID that generated the message. It should be either ID of the log observer application
* or the ID of the log collector service.
* \param target The target ID to receive the message. This target can be either concrete connected client
* or can be NEService::COOKIE_ANY if should be forwarded to all connected clients.
* or can be NEService::TARGET_ALL if should be forwarded to all connected clients.
* \return Returns generated message ready to send to client(s) via log collector service.
**/
AREG_API RemoteMessage messageSaveConfiguration(const ITEM_ID & source, const ITEM_ID & target);
Expand Down
4 changes: 2 additions & 2 deletions framework/areglogger/client/LogObserverBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class LOGGER_API LogObserverBase
* \brief Requests to update the priority of the logging message to receive.
* The indicated scopes can be scope group.
* \param target The valid cookie ID of the target to update the log message priority.
* This value cannot be NEService::TARGET_ALL (or 0).
* This value cannot be NEService::TARGET_ALL (or 0xFF).
* \param scopes The list of scopes of scope group to update the priority.
* The scope group should end with '*'. For example 'areg_base_*'.
* In this case the ID of the scope can be 0.
Expand All @@ -276,7 +276,7 @@ class LOGGER_API LogObserverBase
* \brief Requests to save current configuration of the specified target. This is normally called when update the log priority of the instance,
* so that on next start the application logs message of the scopes and priorities currently set.
* \param target The cookie ID of the target instance to save the configuration.
* If the target is NEService::TARGET_ALL (or 0), the request is sent to all connected instances.
* If the target is NEService::TARGET_ALL (or 0xFF), the request is sent to all connected instances.
* Otherwise, should be indicated the valid cookie ID of the connected log instance.
* \return Returns true if processed with success. Otherwise, returns false.
**/
Expand Down
18 changes: 9 additions & 9 deletions framework/areglogger/client/private/LoggerClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,37 +187,37 @@ bool LoggerClient::requestConnectedInstances(void)
return result;
}

bool LoggerClient::requestScopes(const ITEM_ID& target /*= NEService::COOKIE_ANY*/)
bool LoggerClient::requestScopes(const ITEM_ID& target /*= NEService::TARGET_ALL*/)
{
bool result{ false };
Lock lock(mLock);
if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::COOKIE_UNKNOWN))
if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::TARGET_UNKNOWN))
{
result = sendMessage(NELogging::messageQueryScopes(mChannel.getCookie(), target == NEService::COOKIE_ANY ? LoggerClient::TargetID : target));
result = sendMessage(NELogging::messageQueryScopes(mChannel.getCookie(), target == NEService::TARGET_ALL ? LoggerClient::TargetID : target));
}

return result;
}

bool LoggerClient::requestChangeScopePrio(const NELogging::ScopeNames & scopes, const ITEM_ID& target /*= NEService::COOKIE_ANY*/)
bool LoggerClient::requestChangeScopePrio(const NELogging::ScopeNames & scopes, const ITEM_ID& target /*= NEService::TARGET_ALL*/)
{
bool result{ false };
Lock lock(mLock);
if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::COOKIE_UNKNOWN))
if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::TARGET_UNKNOWN))
{
result = sendMessage(NELogging::messageUpdateScopes(mChannel.getCookie(), target == NEService::COOKIE_ANY ? LoggerClient::TargetID : target, scopes));
result = sendMessage(NELogging::messageUpdateScopes(mChannel.getCookie(), target == NEService::TARGET_ALL ? LoggerClient::TargetID : target, scopes));
}

return result;
}

bool LoggerClient::requestSaveConfiguration(const ITEM_ID& target /*= NEService::COOKIE_ANY*/)
bool LoggerClient::requestSaveConfiguration(const ITEM_ID& target /*= NEService::TARGET_ALL*/)
{
bool result{ false };
Lock lock(mLock);
if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::COOKIE_UNKNOWN))
if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::TARGET_UNKNOWN))
{
result = sendMessage(NELogging::messageSaveConfiguration(mChannel.getCookie(), target == NEService::COOKIE_ANY ? LoggerClient::TargetID : target));
result = sendMessage(NELogging::messageSaveConfiguration(mChannel.getCookie(), target == NEService::TARGET_ALL ? LoggerClient::TargetID : target));
}

return result;
Expand Down
18 changes: 9 additions & 9 deletions framework/areglogger/client/private/LoggerClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,37 +180,37 @@ class LoggerClient : public ServiceClientConnectionBase
/**
* \brief Generates and sends the message to query list of scopes.
* The message is sent either to certain target or to all connected clients
* if the target is NEService::COOKIE_ANY.
* if the target is NEService::TARGET_ALL.
* \param target The ID of the target to send the message.
* The message is sent to all clients if the target is NEService::COOKIE_ANY.
* The message is sent to all clients if the target is NEService::TARGET_ALL.
* \return Returns true if processed the request with success. Otherwise, returns false.
**/
bool requestScopes(const ITEM_ID& target = NEService::COOKIE_ANY);
bool requestScopes(const ITEM_ID& target = NEService::TARGET_ALL);

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

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

/**
* \brief Creates of opens the database for the logging. If specified path is null or empty,
Expand Down
2 changes: 1 addition & 1 deletion framework/logcollector/app/LogCollector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class LogCollector : public ServiceApplicationBase
* \param optScope The option entry that contains scope priority update instruction.
* If the command contains a list of scopes to update, the should be split by ';'.
* \param msgList On output it contains a list a messages to send to the targets.
* If a message is referred to all connected clients, the target is NEService::COOKIE_ANY.
* If a message is referred to all connected clients, the target is NEService::TARGET_ALL.
**/
static void _createScopeMessage(const OptionParser::sOption& optScope, TEArrayList<RemoteMessage> & OUT msgList);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ void LogCollectorMessageProcessor::queryConnectedInstances(const RemoteMessage &
}
}

void LogCollectorMessageProcessor::notifyConnectedInstances(const NEService::MapInstances& instances, const ITEM_ID& target /*= NEService::COOKIE_ANY*/) const
void LogCollectorMessageProcessor::notifyConnectedInstances(const NEService::MapInstances& instances, const ITEM_ID& target /*= NEService::TARGET_ALL*/) const
{
const auto& observers{ mLoggerService.getObservers() };
if (observers.isEmpty())
return;

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

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

if (target == NEService::COOKIE_ANY)
if (target == NEService::TARGET_ALL)
{
for (const auto& observer : observers.getData())
{
Expand Down Expand Up @@ -105,7 +105,7 @@ void LogCollectorMessageProcessor::notifyDisconnectedInstances(const TEArrayList
{
msgInstances << NERemoteService::eRemoteConnection::RemoteDisconnected;
msgInstances << listIds;
if (target == NEService::COOKIE_ANY)
if (target == NEService::TARGET_ALL)
{
for (const auto& observer : observers.getData())
{
Expand Down Expand Up @@ -156,7 +156,7 @@ void LogCollectorMessageProcessor::saveLogSourceConfiguration(const RemoteMessag

ITEM_ID target{ NEService::COOKIE_UNKNOWN };
msgReceived >> target;
if ((target == NEService::COOKIE_ANY) || (target == NEService::COOKIE_LOGGER))
if ((target == NEService::TARGET_ALL) || (target == NEService::COOKIE_LOGGER))
{
const NEService::MapInstances& instances{ mLoggerService.getInstances() };
for (const auto& entry : instances.getData())
Expand Down Expand Up @@ -212,7 +212,7 @@ void LogCollectorMessageProcessor::processNextSaveConfig(void)

void LogCollectorMessageProcessor::clientDisconnected(const ITEM_ID& cookie)
{
if ((cookie > NEService::COOKIE_ANY) && (mPendingSave == cookie))
if ((cookie > NEService::TARGET_ALL) && (mPendingSave == cookie))
{
processNextSaveConfig();
}
Expand Down Expand Up @@ -254,7 +254,7 @@ inline void LogCollectorMessageProcessor::_forwardMessageToLogSources(const Remo
return;

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

auto srcPos = source != NEService::COOKIE_LOGGER ? instances.find(source) : instances.invalidPosition();
if ((source == NEService::COOKIE_LOGGER) || (instances.isValidPosition(srcPos) && isLogObserver(instances.valueAtPosition(srcPos).ciSource)))
Expand All @@ -264,7 +264,7 @@ inline void LogCollectorMessageProcessor::_forwardMessageToLogSources(const Remo
{
mLoggerService.sendMessage(msgReceived);
}
else if (target == NEService::COOKIE_ANY)
else if (target == NEService::TARGET_ALL)
{
for (const auto& instance : instances.getData())
{
Expand All @@ -285,7 +285,7 @@ inline void LogCollectorMessageProcessor::_forwardMessageToObservers(const Remot
return;

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

auto srcPos = instances.find(source);
Expand All @@ -296,7 +296,7 @@ inline void LogCollectorMessageProcessor::_forwardMessageToObservers(const Remot
{
mLoggerService.sendMessage(msgReceived);
}
else if (target == NEService::COOKIE_ANY)
else if (target == NEService::TARGET_ALL)
{
for (const auto& observer : observers.getData())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,25 @@ class LogCollectorMessageProcessor

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

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

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

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

/**
* \brief Forwards specified message to the log observer.
* If the target in the remote message is NEService::COOKIE_ANY, the message is sent to all observers.
* If the target in the remote message is NEService::TARGET_ALL, the message is sent to all observers.
* \param msgReceived The remote message received from a client.
**/
inline void _forwardMessageToObservers(const RemoteMessage& msgReceived) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void LogCollectorServerService::addInstance(const ITEM_ID& cookie, const NEServi
, instance.ciLocation.c_str());
NELogging::logAnyMessageLocal(logMsgHello);

mLoggerProcessor.notifyConnectedInstances(getInstances(), NEService::COOKIE_ANY);
mLoggerProcessor.notifyConnectedInstances(getInstances(), NEService::TARGET_ALL);
}
else if (LogCollectorMessageProcessor::isLogObserver(instance.ciSource))
{
Expand Down Expand Up @@ -86,7 +86,7 @@ void LogCollectorServerService::removeInstance(const ITEM_ID & cookie)
NELogging::logAnyMessageLocal(logMsgBye);

listIds.add(instance.ciCookie);
mLoggerProcessor.notifyDisconnectedInstances(listIds, NEService::COOKIE_ANY);
mLoggerProcessor.notifyDisconnectedInstances(listIds, NEService::TARGET_ALL);
}
else if (LogCollectorMessageProcessor::isLogObserver(instance.ciSource))
{
Expand Down Expand Up @@ -118,7 +118,7 @@ void LogCollectorServerService::removeAllInstances(void)

if (listIds.isEmpty() == false)
{
mLoggerProcessor.notifyDisconnectedInstances(listIds, NEService::COOKIE_ANY);
mLoggerProcessor.notifyDisconnectedInstances(listIds, NEService::TARGET_ALL);
}
}

Expand Down
Loading