Refactor WebSocket server message handling to include user data

- Update sendMessageToConnection to accept user data, enhancing message delivery accuracy.
- Improve error handling in WebSocket callbacks by adding user data checks to prevent null pointer exceptions.
- Enhance logging for error responses to provide clearer insights into message handling issues.
This commit is contained in:
Torsten Schulz (local)
2025-11-20 17:10:46 +01:00
committed by Torsten (PC)
parent 88f6686809
commit 0c36c4a4e5
2 changed files with 30 additions and 13 deletions

View File

@@ -52,6 +52,7 @@ private:
bool isMainAdmin(const std::string &hashedUserId);
nlohmann::json getActiveConnections();
void sendMessageToConnection(struct lws *wsi, const std::string &message);
void sendMessageToConnection(struct lws *wsi, WebSocketUserData *ud, const std::string &message);
void addConnection(const std::string &userId, struct lws *wsi);
void removeConnection(const std::string &userId, struct lws *wsi);
void removeConnectionByWsi(struct lws *wsi); // Entfernt Verbindung aus allen Einträgen (Fallback)