Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

broadcast.h 854B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef BROADCAST_H
  2. #define BROADCAST_H
  3. #include <QUdpSocket>
  4. #include <QPair>
  5. #include "ptsocket.h"
  6. #include "libptsocket_global.h"
  7. typedef QPair<quint32, quint16> BcClient;
  8. class LIBPTSOCKETSHARED_EXPORT Broadcast : public QObject
  9. {
  10. Q_OBJECT
  11. public:
  12. Broadcast(bool isServer, QObject* p = 0);
  13. bool isServer() const;
  14. QString getError() const;
  15. static QByteArray clientData();
  16. static QByteArray serverData();
  17. signals:
  18. void serverDiscovered(QHostAddress, quint16);
  19. public slots:
  20. void setTimeout(int t);
  21. void setBroadcastInterval(int i);
  22. bool start(int port, int r, QHostAddress ad = QHostAddress::Any);
  23. void broadcastClient();
  24. private slots:
  25. void readyRead();
  26. void clearData();
  27. private:
  28. QUdpSocket* m_server;
  29. bool m_isServer;
  30. QTimer m_timeoutTimer;
  31. QTimer m_bcTimer;
  32. QMap<BcClient, QByteArray> m_data;
  33. int m_remotePort;
  34. };
  35. #endif