- Füge die JSON-Bibliothek in `ssl_server.h` hinzu, um JSON-Funktionalitäten zu unterstützen. - Ergänze die Methode `generateToken` in `base.h`, um die Token-Generierung zu ermöglichen. - Aktualisiere die Header-Dateien, um neue Methoden und Abhängigkeiten zu berücksichtigen.
37 lines
1.1 KiB
C++
Executable File
37 lines
1.1 KiB
C++
Executable File
#ifndef YC_LIB_BASE_H
|
|
#define YC_LIB_BASE_H
|
|
|
|
#include <json/json.h>
|
|
|
|
namespace Yc {
|
|
namespace Lib {
|
|
|
|
class Base {
|
|
public:
|
|
static std::string getJsonString(const Json::Value& json);
|
|
static Json::Value getJsonTree(const std::string& msg);
|
|
|
|
// Neue öffentliche Helper zum Entfernen aller "token"-Felder
|
|
static void sanitizeTokens(Json::Value& v);
|
|
static void sanitizeTokensInString(std::string& s);
|
|
static std::string generateToken();
|
|
|
|
protected:
|
|
void send(int socket, std::string out);
|
|
void send(int socket, Json::Value out);
|
|
std::string readSocket(int socket);
|
|
// WebSocket helpers (server-side): read one text frame and send a text frame
|
|
std::string readWebSocketMessage(int socket);
|
|
void sendWebSocketMessage(int socket, const std::string& out);
|
|
// WebSocket connection tracking and handshake helpers
|
|
static void markWebSocket(int socket);
|
|
static void unmarkWebSocket(int socket);
|
|
static bool isWebSocket(int socket);
|
|
static std::string webSocketAcceptKey(const std::string& clientKey);
|
|
};
|
|
|
|
} // namespace Lib
|
|
} // namespace Yc
|
|
|
|
#endif // YC_LIB_BASE_H
|