From 52204a9eecdf2ca743ee5a20198d80b71b8ede10 Mon Sep 17 00:00:00 2001 From: tt2468 Date: Mon, 14 Jun 2021 20:50:50 -0700 Subject: [PATCH] WebSocketServer: Log connects and disconnects --- src/WebSocketServer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/WebSocketServer.cpp b/src/WebSocketServer.cpp index cfeb747d..418e5ba4 100644 --- a/src/WebSocketServer.cpp +++ b/src/WebSocketServer.cpp @@ -298,6 +298,9 @@ void WebSocketServer::onOpen(websocketpp::connection_hdl hdl) // Emit signals emit ClientConnected(state); + // Log connection + blog(LOG_INFO, "[WebSocketServer::onOpen] New WebSocket client has connected from %s", session->RemoteAddress().c_str()); + // Send object to client websocketpp::lib::error_code errorCode; auto sessionEncoding = session->Encoding(); @@ -338,6 +341,9 @@ void WebSocketServer::onClose(websocketpp::connection_hdl hdl) // Emit signals emit ClientDisconnected(state, conn->get_local_close_code()); + // Log disconnection + blog(LOG_INFO, "[WebSocketServer::onClose] WebSocket client %s has disconnected", remoteAddress.c_str()); + // Get config for tray notification auto conf = GetConfig(); if (!conf) {