Vitaly Buka | 4615e0d | 2015-10-14 15:35:12 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Weave Authors. All rights reserved. |
Vitaly Buka | 0bd3213 | 2015-07-30 15:54:48 -0700 | [diff] [blame] | 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 LIBWEAVE_SRC_PRIVET_PUBLISHER_H_ |
| 6 | #define LIBWEAVE_SRC_PRIVET_PUBLISHER_H_ |
| 7 | |
| 8 | #include <memory> |
| 9 | #include <string> |
Vitaly Buka | 8589b05 | 2015-09-29 00:46:14 -0700 | [diff] [blame] | 10 | #include <vector> |
Vitaly Buka | 0bd3213 | 2015-07-30 15:54:48 -0700 | [diff] [blame] | 11 | |
| 12 | #include <base/macros.h> |
| 13 | |
Vitaly Buka | 0bd3213 | 2015-07-30 15:54:48 -0700 | [diff] [blame] | 14 | namespace weave { |
| 15 | |
Vitaly Buka | 1e36367 | 2015-09-25 14:01:16 -0700 | [diff] [blame] | 16 | namespace provider { |
| 17 | class DnsServiceDiscovery; |
| 18 | } |
Vitaly Buka | 0bd3213 | 2015-07-30 15:54:48 -0700 | [diff] [blame] | 19 | |
| 20 | namespace privet { |
| 21 | |
| 22 | class CloudDelegate; |
| 23 | class DeviceDelegate; |
| 24 | class WifiDelegate; |
| 25 | |
Vitaly Buka | beddc60 | 2015-09-24 15:28:03 -0700 | [diff] [blame] | 26 | // Publishes privet service on DNS-SD. |
Johan Euphrosine | 0b7bb9f | 2015-09-29 01:11:21 -0700 | [diff] [blame] | 27 | class Publisher { |
Vitaly Buka | 0bd3213 | 2015-07-30 15:54:48 -0700 | [diff] [blame] | 28 | public: |
| 29 | Publisher(const DeviceDelegate* device, |
| 30 | const CloudDelegate* cloud, |
| 31 | const WifiDelegate* wifi, |
Vitaly Buka | 1e36367 | 2015-09-25 14:01:16 -0700 | [diff] [blame] | 32 | provider::DnsServiceDiscovery* dns_sd); |
Johan Euphrosine | 0b7bb9f | 2015-09-29 01:11:21 -0700 | [diff] [blame] | 33 | ~Publisher(); |
Vitaly Buka | 0bd3213 | 2015-07-30 15:54:48 -0700 | [diff] [blame] | 34 | |
| 35 | // Updates published information. Removes service if HTTP is not alive. |
| 36 | void Update(); |
| 37 | |
| 38 | private: |
| 39 | void ExposeService(); |
| 40 | void RemoveService(); |
| 41 | |
Vitaly Buka | 1e36367 | 2015-09-25 14:01:16 -0700 | [diff] [blame] | 42 | provider::DnsServiceDiscovery* dns_sd_{nullptr}; |
Vitaly Buka | 0bd3213 | 2015-07-30 15:54:48 -0700 | [diff] [blame] | 43 | |
| 44 | const DeviceDelegate* device_{nullptr}; |
| 45 | const CloudDelegate* cloud_{nullptr}; |
| 46 | const WifiDelegate* wifi_{nullptr}; |
| 47 | |
Vitaly Buka | 8589b05 | 2015-09-29 00:46:14 -0700 | [diff] [blame] | 48 | std::pair<uint16_t, std::vector<std::string>> published_; |
| 49 | |
Vitaly Buka | 0bd3213 | 2015-07-30 15:54:48 -0700 | [diff] [blame] | 50 | DISALLOW_COPY_AND_ASSIGN(Publisher); |
| 51 | }; |
| 52 | |
| 53 | } // namespace privet |
| 54 | } // namespace weave |
| 55 | |
| 56 | #endif // LIBWEAVE_SRC_PRIVET_PUBLISHER_H_ |