• ZeroConfServiceBrowser
  • ZeroConfServiceBrowser Class

    Allows to browse avahi services in the local network. More...

    Header: #include <ZeroConfServiceBrowser>
    Inherits:

    Public Functions

    ZeroConfServiceBrowser(const QString & serviceType = QString(), QObject * parent = nullptr)
    virtual ~ZeroConfServiceBrowser()
    virtual QList<ZeroConfServiceEntry> serviceEntries() const

    Signals

    void serviceEntryAdded(const ZeroConfServiceEntry & entry)
    void serviceEntryRemoved(const ZeroConfServiceEntry & entry)

    Detailed Description

    Allows to browse avahi services in the local network.

    The ZeroConfServiceBrowser allows to discover the avahi network and get services.

    Example

    In order to search for available avahi services in the current network you use this hardware resource like this:

    devicepluginexample.h

    #include "network/avahi/ZeroConfServiceEntry.h"
    
    class DevicePluginExample : public DevicePlugin
    {
    ...
    
    public:
        void init() override;
    
    private slots:
        void onServiceEntryAdded(const ZeroConfServiceEntry &serviceEntry);
        void onServiceEntryRemoved(const ZeroConfServiceEntry &serviceEntry);
    
    ...
    
    };

    devicepluginexample.cpp

    void DevicePluginExample::init() {
        connect(hardwareManager()->avahiBrowser(), &ZeroConfServiceBrowser::serviceEntryAdded, this, &DevicePluginExample::onServiceEntryAdded);
        connect(hardwareManager()->avahiBrowser(), &ZeroConfServiceBrowser::serviceEntryRemoved, this, &DevicePluginExample::onServiceEntryRemoved);
    }
    
    void DevicePluginExample::onServiceEntryAdded(const ZeroConfServiceEntry &serviceEntry) {
        qCDebug(dcExample()) << "New service added to network:" << serviceEntry;
    
        ...
    }
    
    void DevicePluginExample::onServiceEntryRemoved(const ZeroConfServiceEntry &serviceEntry) {
        qCDebug(dcExample()) << "Service removed from network:" << serviceEntry;
    
        ...
    }

    See also ZeroConfServiceEntry.

    Member Function Documentation

    ZeroConfServiceBrowser::ZeroConfServiceBrowser(const QString & serviceType = QString(), QObject * parent = nullptr)

    Constructs a new ZeroConfServiceBrowser with the given parent.

    [virtual] ZeroConfServiceBrowser::~ZeroConfServiceBrowser()

    Destroys this ZeroConfServiceBrowser;

    [virtual] QList<ZeroConfServiceEntry> ZeroConfServiceBrowser::serviceEntries() const

    Returns the list of available service entries in the network of this browser.

    [signal] void ZeroConfServiceBrowser::serviceEntryAdded(const ZeroConfServiceEntry & entry)

    This signal will be emitted when a new entry was added to the current entry list.

    [signal] void ZeroConfServiceBrowser::serviceEntryRemoved(const ZeroConfServiceEntry & entry)

    This signal will be emitted when a new entry was removed from the current entry list.