Füge Unterstützung für die Verwaltung von WebSocket-Verbindungen hinzu. Implementiere Methoden zum Hinzufügen und Entfernen von Verbindungen basierend auf Benutzer-IDs. Aktualisiere die WebSocket-Callback-Logik, um empfangene Nachrichten zu verarbeiten und Benutzer-IDs zu setzen. Verbessere die Ausgabe von Debug-Informationen zur Nachverfolgung von Verbindungen und Nachrichten.
This commit is contained in:
committed by
Torsten (PC)
parent
c9dc891481
commit
e7a8dc86eb
@@ -19,6 +19,7 @@
|
||||
struct WebSocketUserData {
|
||||
std::string userId;
|
||||
bool pongReceived = true;
|
||||
std::string pendingMessage;
|
||||
};
|
||||
|
||||
class Worker; // forward
|
||||
@@ -39,6 +40,8 @@ private:
|
||||
void pingClients();
|
||||
void handleBrokerMessage(const std::string &message);
|
||||
std::string getUserIdFromFalukantUserId(int falukantUserId);
|
||||
void addConnection(const std::string &userId, struct lws *wsi);
|
||||
void removeConnection(const std::string &userId);
|
||||
|
||||
static int wsCallback(struct lws *wsi,
|
||||
enum lws_callback_reasons reason,
|
||||
@@ -67,4 +70,5 @@ private:
|
||||
std::vector<Worker*> workers;
|
||||
|
||||
static struct lws_protocols protocols[];
|
||||
static WebSocketServer* instance;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user