UdpClient.h 598 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef UDPCLIENT_H
  2. #define UDPCLIENT_H
  3. #include <functional>
  4. #include <memory>
  5. #include <string>
  6. namespace Network {
  7. class m_pUdpClientImpl;
  8. class UdpClient
  9. {
  10. public:
  11. UdpClient(const std::string& listenAddress, const std::string& targetAddress, int targetPort, std::function<void(const std::string&)> callback);
  12. ~UdpClient();
  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<UdpClientImpl> m_pUdpClientImpl;
  19. };
  20. } // namespace Network
  21. #endif // UDPCLIENT_H