diff --git a/src/core/ssl_server.cpp b/src/core/ssl_server.cpp index 8474939..30552a6 100644 --- a/src/core/ssl_server.cpp +++ b/src/core/ssl_server.cpp @@ -17,7 +17,7 @@ SSLServer* SSLServer::_instance = nullptr; // Protocols array definition struct lws_protocols SSLServer::_protocols[] = { { - "yourchat-protocol", + "chat", SSLServer::wsCallback, sizeof(WebSocketUserData), 4096 @@ -110,6 +110,9 @@ void SSLServer::startServer() { std::cout << "[YourChat] WebSocket Server starting on port " << _port << " (no SSL)" << std::endl; } + // WebSocket-spezifische Optionen + info.options |= LWS_SERVER_OPTION_HTTP_HEADERS_SECURITY_BEST_PRACTICES_ENFORCE; + // Reduziere Log-Level um weniger Debug-Ausgaben zu haben setenv("LWS_LOG_LEVEL", "0", 1); // 0 = nur Fehler @@ -159,8 +162,14 @@ int SSLServer::wsCallback(struct lws *wsi, enum lws_callback_reasons reason, voi switch (reason) { case LWS_CALLBACK_ESTABLISHED: std::cout << "[YourChat] WebSocket-Verbindung hergestellt" << std::endl; + // Request callback when writable to send initial message + lws_callback_on_writable(wsi); break; + case LWS_CALLBACK_HTTP: + std::cout << "[YourChat] HTTP request received, upgrading to WebSocket" << std::endl; + return 0; + case LWS_CALLBACK_RECEIVE: { std::string msg(reinterpret_cast(in), len); std::cout << "[YourChat] WebSocket-Nachricht empfangen: " << msg << std::endl;