12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #ifndef BROADCAST_H
- #define BROADCAST_H
-
- #include <QUdpSocket>
- #include <QPair>
- #include "ptsocket.h"
- #include "libptsocket_global.h"
-
- typedef QPair<quint32, quint16> BcClient;
-
- class LIBPTSOCKETSHARED_EXPORT Broadcast : public QObject
- {
- Q_OBJECT
- public:
- Broadcast(bool isServer, QObject* p = 0);
- bool isServer() const;
- QString getError() const;
- static QByteArray clientData();
- static QByteArray serverData();
-
- signals:
- void serverDiscovered(QHostAddress, quint16);
-
- public slots:
- void setTimeout(int t);
- void setBroadcastInterval(int i);
- bool start(int port, int r, QHostAddress ad = QHostAddress::Any);
- void broadcastClient();
-
- private slots:
- void readyRead();
- void clearData();
-
- private:
- QUdpSocket* m_server;
- bool m_isServer;
- QTimer m_timeoutTimer;
- QTimer m_bcTimer;
- QMap<BcClient, QByteArray> m_data;
- int m_remotePort;
- };
-
- #endif
|