Enhance logging and error handling in getConnections callback
- Add detailed logging to track the flow and validity of user data during the getConnections event. - Implement exception handling to manage potential access issues with user data, improving stability and error visibility. - Ensure clear output for both successful and failed user data access attempts, aiding in debugging and monitoring.
This commit is contained in:
committed by
Torsten (PC)
parent
127e95ca1c
commit
d5a09f359d
@@ -320,10 +320,22 @@ int WebSocketServer::wsCallback(struct lws *wsi,
|
|||||||
}
|
}
|
||||||
} else if (event == "getConnections") {
|
} else if (event == "getConnections") {
|
||||||
// Admin-Funktion: Liste aller aktiven Verbindungen
|
// Admin-Funktion: Liste aller aktiven Verbindungen
|
||||||
|
std::cout << "[RECEIVE] getConnections: Start" << std::endl;
|
||||||
if (!ud) {
|
if (!ud) {
|
||||||
std::cerr << "[RECEIVE] getConnections: ud ist nullptr" << std::endl;
|
std::cerr << "[RECEIVE] getConnections: ud ist nullptr" << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
std::cout << "[RECEIVE] getConnections: ud ist gültig" << std::endl;
|
||||||
|
|
||||||
|
// Prüfe ob ud noch gültig ist, bevor wir darauf zugreifen
|
||||||
|
try {
|
||||||
|
volatile bool test = ud->pongReceived;
|
||||||
|
(void)test;
|
||||||
|
std::cout << "[RECEIVE] getConnections: ud-Zugriff erfolgreich" << std::endl;
|
||||||
|
} catch (...) {
|
||||||
|
std::cerr << "[RECEIVE] getConnections: ud ist ungültig (Exception beim Zugriff)" << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (ud->userId.empty()) {
|
if (ud->userId.empty()) {
|
||||||
std::cerr << "[RECEIVE] getConnections: User-ID nicht gesetzt" << std::endl;
|
std::cerr << "[RECEIVE] getConnections: User-ID nicht gesetzt" << std::endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user