From d20b4188aae130778bcb6b9fea574ec94f4527f9 Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Sat, 12 May 2018 14:41:55 +0300 Subject: [PATCH] Added the function ReadyRead, which accepts datagrams. --- src/network.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/network.cpp b/src/network.cpp index 7c86cd6..4254a26 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -25,4 +25,14 @@ class Network out << qint64(data.size() - sizeof(qint64)); socket->writeDatagram(data, QHostAddress(ip), 6552); } + void readyRead() + { + QByteArray buffer; + buffer.resize(socket->pendingDatagramSize()); + QHostAddress sender; + socket->readDatagram(buffer.data(), buffer.size(), + &sender;, &senderPort;); + qDebug() << "Message from: " << sender.toString(); + qDebug() << "Message: " << buffer; + } }