From a05bd9537bd01bbe680f7224f42acd4bd40899ab Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 4 Aug 2019 20:51:52 -0500 Subject: [PATCH] Add logging for bad messages and listen on 0.0.0.0 --- src/server.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/server.cpp b/src/server.cpp index 4193a63..94ea2d2 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -32,13 +32,15 @@ void DataFeed::handleInit() { void DataFeed::read() { while (m_dev->bytesAvailable()) { - const auto doc = QJsonDocument::fromJson(m_dev->readLine()); + auto json = m_dev->readLine(); + const auto doc = QJsonDocument::fromJson(json); if (m_procData) { const auto msg = doc.object(); if (msg["type"] == "TraceEvent") { - const auto te = msg["data"].toObject(); - m_procData->traceEvents.push_back(te); + m_procData->traceEvents.push_back(msg["data"].toObject()); emit m_procData->traceEvent(m_procData->traceEvents.last()); + } else { + qDebug().noquote() << "Bad message:" << json; } } } @@ -46,7 +48,7 @@ void DataFeed::read() { LogServer::LogServer() { - m_server->listen(QHostAddress::LocalHost, 5590); + m_server->listen(QHostAddress::Any, 5590); connect(m_server, &QTcpServer::newConnection, this, &LogServer::handleConnection); }