1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef DISCOVERY_MDNS_MDNS_SENDER_H_ 6 #define DISCOVERY_MDNS_MDNS_SENDER_H_ 7 8 #include "platform/api/udp_socket.h" 9 #include "platform/base/error.h" 10 #include "platform/base/ip_address.h" 11 12 namespace openscreen { 13 namespace discovery { 14 15 class MdnsMessage; 16 17 class MdnsSender { 18 public: 19 // MdnsSender does not own |socket| and expects that its lifetime exceeds the 20 // lifetime of MdnsSender. 21 explicit MdnsSender(UdpSocket* socket); 22 MdnsSender(const MdnsSender& other) = delete; 23 MdnsSender(MdnsSender&& other) noexcept = delete; 24 virtual ~MdnsSender(); 25 26 MdnsSender& operator=(const MdnsSender& other) = delete; 27 MdnsSender& operator=(MdnsSender&& other) noexcept = delete; 28 29 virtual Error SendMulticast(const MdnsMessage& message); 30 virtual Error SendMessage(const MdnsMessage& message, 31 const IPEndpoint& endpoint); 32 33 void OnSendError(UdpSocket* socket, Error error); 34 35 private: 36 UdpSocket* const socket_; 37 }; 38 39 } // namespace discovery 40 } // namespace openscreen 41 42 #endif // DISCOVERY_MDNS_MDNS_SENDER_H_ 43