|
|
@ -1,3 +1,4 @@ |
|
|
|
#include "logger.h" |
|
|
|
#include "socket.h" |
|
|
|
|
|
|
|
UdpSocket::UdpSocket(QObject* parent, quint16 port) : |
|
|
@ -31,14 +32,6 @@ void UdpSocket::sayMsg(const QString& msg) |
|
|
|
_socket->writeDatagram(Data, QHostAddress::LocalHost, _port); |
|
|
|
} |
|
|
|
|
|
|
|
/*******************************************************************************************/ |
|
|
|
void UdpSocket::logReceivedData(const QHostAddress& addr, quint16 port, const QByteArray& msg) const |
|
|
|
{ |
|
|
|
qDebug() << "Address : " << addr.toString(); |
|
|
|
qDebug() << "Port : " << port; |
|
|
|
qDebug() << "Content : " << msg << '\n'; |
|
|
|
} |
|
|
|
|
|
|
|
/*******************************************************************************************/ |
|
|
|
void UdpSocket::readyRead() |
|
|
|
{ |
|
|
@ -47,5 +40,5 @@ void UdpSocket::readyRead() |
|
|
|
QHostAddress sender_addr; |
|
|
|
quint16 sender_port; |
|
|
|
_socket->readDatagram(buffer.data(), buffer.size(), &sender_addr, &sender_port); |
|
|
|
logReceivedData(sender_addr, sender_port, buffer); |
|
|
|
Logger::logReceivedData(buffer, sender_addr, sender_port); |
|
|
|
} |
|
|
|