join multicast group on all interfaces
This commit is contained in:
parent
b2facb639a
commit
92b211056e
|
@ -2,9 +2,15 @@
|
|||
|
||||
#include <QDebug>
|
||||
#include <QNetworkDatagram>
|
||||
#include <QNetworkInterface>
|
||||
|
||||
namespace SACN {
|
||||
|
||||
/**
|
||||
* @brief QSacnNode::QSacnNode
|
||||
* @param parent
|
||||
* @param cid
|
||||
*/
|
||||
QSacnNode::QSacnNode(QObject *parent, QUuid cid)
|
||||
: Appliance(UUID::uuid(cid.toString().toStdString()))
|
||||
, QUdpSocket(parent)
|
||||
|
@ -22,6 +28,10 @@ QSacnNode::QSacnNode(QObject *parent, QUuid cid)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief QSacnNode::subscribe
|
||||
* @param num
|
||||
*/
|
||||
void QSacnNode::subscribe(const uint16_t num)
|
||||
{
|
||||
if (Receiver::universe(num)) // already subscribed
|
||||
|
@ -31,13 +41,20 @@ void QSacnNode::subscribe(const uint16_t num)
|
|||
Receiver::subscribe(num);
|
||||
universes_.insert(num, new QSacnUniverse(this, Receiver::universe(num)));
|
||||
}
|
||||
joinMulticastGroup(IPv4MulticastAddress(num));
|
||||
for (QNetworkInterface &iface : QNetworkInterface::allInterfaces())
|
||||
joinMulticastGroup(IPv4MulticastAddress(num), iface);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief QSacnNode::unsubscribe
|
||||
* @param num
|
||||
*/
|
||||
void QSacnNode::unsubscribe(const uint16_t num)
|
||||
{
|
||||
leaveMulticastGroup(IPv4MulticastAddress(num));
|
||||
for (QNetworkInterface &iface : QNetworkInterface::allInterfaces())
|
||||
leaveMulticastGroup(IPv4MulticastAddress(num), iface);
|
||||
|
||||
if (Receiver::universe(num)) {
|
||||
qDebug() << "Unsubscribing from universe " << QString::number(num);
|
||||
delete universes_.take(num);
|
||||
|
@ -46,6 +63,9 @@ void QSacnNode::unsubscribe(const uint16_t num)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief QSacnNode::UdpPayloadReceiver
|
||||
*/
|
||||
void QSacnNode::UdpPayloadReceiver()
|
||||
{
|
||||
while (hasPendingDatagrams()) {
|
||||
|
@ -63,7 +83,12 @@ void QSacnNode::UdpPayloadReceiver()
|
|||
}
|
||||
|
||||
|
||||
// wrap callback to Qt signal
|
||||
/**
|
||||
* @brief QSacnNode::emitFound
|
||||
* @param univ
|
||||
*
|
||||
* wrap data change callback to a Qt signal
|
||||
*/
|
||||
void QSacnNode::emitFound(
|
||||
std::shared_ptr<EXTENDED::DISCOVERY::DiscoveredUniverse> univ)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue