BroadcastServer.h 618 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef BROADCASTSERVER_H
  2. #define BROADCASTSERVER_H
  3. #include <functional>
  4. #include <memory>
  5. #include <string>
  6. namespace Network {
  7. class BroadcastServerImpl;
  8. class BroadcastServer
  9. {
  10. public:
  11. BroadcastServer(const std::string& listenAddress, int broadcastPort, std::function<void(const std::string&)> callback);
  12. ~BroadcastServer();
  13. public:
  14. void Receive();
  15. std::string Send(const std::string& data, int sourcePort = 0);
  16. void Broadcast(const std::string& data, int sourcePort = 0);
  17. private:
  18. std::unique_ptr<BroadcastServerImpl> m_pBroadcastServerImpl;
  19. };
  20. } // namespace Network
  21. #endif // BROADCASTSERVER_H