Add logging for bad messages and listen on 0.0.0.0

This commit is contained in:
Gary Talent 2019-08-04 20:51:52 -05:00
parent 8bd53abf65
commit a05bd9537b

View File

@ -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);
}