• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 The Weave 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 LIBWEAVE_SRC_PRIVET_PUBLISHER_H_
6 #define LIBWEAVE_SRC_PRIVET_PUBLISHER_H_
7 
8 #include <memory>
9 #include <string>
10 #include <vector>
11 
12 #include <base/macros.h>
13 
14 namespace weave {
15 
16 namespace provider {
17 class DnsServiceDiscovery;
18 }
19 
20 namespace privet {
21 
22 class CloudDelegate;
23 class DeviceDelegate;
24 class WifiDelegate;
25 
26 // Publishes privet service on DNS-SD.
27 class Publisher {
28  public:
29   Publisher(const DeviceDelegate* device,
30             const CloudDelegate* cloud,
31             const WifiDelegate* wifi,
32             provider::DnsServiceDiscovery* dns_sd);
33   ~Publisher();
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 
42   provider::DnsServiceDiscovery* dns_sd_{nullptr};
43 
44   const DeviceDelegate* device_{nullptr};
45   const CloudDelegate* cloud_{nullptr};
46   const WifiDelegate* wifi_{nullptr};
47 
48   std::pair<uint16_t, std::vector<std::string>> published_;
49 
50   DISALLOW_COPY_AND_ASSIGN(Publisher);
51 };
52 
53 }  // namespace privet
54 }  // namespace weave
55 
56 #endif  // LIBWEAVE_SRC_PRIVET_PUBLISHER_H_
57