28 lines
486 B
C++
28 lines
486 B
C++
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <QUdpSocket>
|
|
#include <QHostAddress>
|
|
#include <QByteArray>
|
|
#include <QDebug>
|
|
|
|
class UdpReceiver : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit UdpReceiver(QObject* parent = nullptr);
|
|
|
|
bool Bind(const QHostAddress& address, quint16 port) {
|
|
return udpSocket_->bind(address, port);
|
|
}
|
|
|
|
Q_SIGNALS:
|
|
void Received(QByteArray datagram);
|
|
|
|
private slots:
|
|
void OnHandleReadyRead();
|
|
|
|
private:
|
|
QUdpSocket* udpSocket_;
|
|
};
|