Updates to BellEngine, ClientManager, ConfigManager, and Telemetry Logging
This commit is contained in:
@@ -2,30 +2,30 @@
|
||||
#include "../Logging/Logging.hpp"
|
||||
|
||||
ClientManager::ClientManager() {
|
||||
LOG_INFO("Client Manager Component - Initialized");
|
||||
LOG_INFO("Client Manager initialized !");
|
||||
}
|
||||
|
||||
ClientManager::~ClientManager() {
|
||||
_clients.clear();
|
||||
LOG_INFO("Client Manager Component - Destroyed");
|
||||
LOG_INFO("Client Manager destroyed");
|
||||
}
|
||||
|
||||
void ClientManager::addClient(AsyncWebSocketClient* client, DeviceType deviceType) {
|
||||
if (!isValidClient(client)) {
|
||||
LOG_ERROR("Cannot add invalid client");
|
||||
LOG_WARNING("Client Manager - Cannot add invalid client");
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t clientId = client->id();
|
||||
_clients[clientId] = ClientInfo(client, deviceType);
|
||||
|
||||
LOG_INFO("Client #%u added as %s device", clientId, deviceTypeToString(deviceType));
|
||||
LOG_INFO("Client Manager - Client #%u added as %s device", clientId, deviceTypeToString(deviceType));
|
||||
}
|
||||
|
||||
void ClientManager::removeClient(uint32_t clientId) {
|
||||
auto it = _clients.find(clientId);
|
||||
if (it != _clients.end()) {
|
||||
LOG_INFO("Client #%u removed (%s device)", clientId,
|
||||
LOG_INFO("Client Manager - Client #%u removed (%s device)", clientId,
|
||||
deviceTypeToString(it->second.deviceType));
|
||||
_clients.erase(it);
|
||||
}
|
||||
@@ -36,7 +36,7 @@ void ClientManager::updateClientType(uint32_t clientId, DeviceType deviceType) {
|
||||
if (it != _clients.end()) {
|
||||
DeviceType oldType = it->second.deviceType;
|
||||
it->second.deviceType = deviceType;
|
||||
LOG_INFO("Client #%u type updated from %s to %s", clientId,
|
||||
LOG_INFO("Client Manager - Client #%u type updated from %s to %s", clientId,
|
||||
deviceTypeToString(oldType), deviceTypeToString(deviceType));
|
||||
}
|
||||
}
|
||||
@@ -72,11 +72,11 @@ bool ClientManager::sendToClient(uint32_t clientId, const String& message) {
|
||||
if (it != _clients.end() && isValidClient(it->second.client)) {
|
||||
it->second.client->text(message);
|
||||
updateClientLastSeen(clientId);
|
||||
LOG_DEBUG("Message sent to client #%u: %s", clientId, message.c_str());
|
||||
LOG_DEBUG("Client Manager - Message sent to client #%u: %s", clientId, message.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
LOG_WARNING("Failed to send message to client #%u - client not found or invalid", clientId);
|
||||
LOG_WARNING("Client Manager - Failed to send message to client #%u - client not found or invalid", clientId);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ void ClientManager::sendToMasterClients(const String& message) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
LOG_DEBUG("Message sent to %d master client(s): %s", count, message.c_str());
|
||||
LOG_DEBUG("Client Manager - Message sent to %d master client(s): %s", count, message.c_str());
|
||||
}
|
||||
|
||||
void ClientManager::sendToSecondaryClients(const String& message) {
|
||||
@@ -103,7 +103,7 @@ void ClientManager::sendToSecondaryClients(const String& message) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
LOG_DEBUG("Message sent to %d secondary client(s): %s", count, message.c_str());
|
||||
LOG_DEBUG("Client Manager - Message sent to %d secondary client(s): %s", count, message.c_str());
|
||||
}
|
||||
|
||||
void ClientManager::broadcastToAll(const String& message) {
|
||||
@@ -115,14 +115,14 @@ void ClientManager::broadcastToAll(const String& message) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
LOG_DEBUG("Message broadcasted to %d client(s): %s", count, message.c_str());
|
||||
LOG_DEBUG("Client Manager - Message broadcasted to %d client(s): %s", count, message.c_str());
|
||||
}
|
||||
|
||||
void ClientManager::cleanupDisconnectedClients() {
|
||||
auto it = _clients.begin();
|
||||
while (it != _clients.end()) {
|
||||
if (!isValidClient(it->second.client)) {
|
||||
LOG_DEBUG("Cleaning up disconnected client #%u", it->first);
|
||||
LOG_DEBUG("Client Manager - Cleaning up disconnected client #%u", it->first);
|
||||
it->second.isConnected = false;
|
||||
it = _clients.erase(it);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user