aboutsummaryrefslogtreecommitdiff
path: root/src/privet/publisher.h
blob: 5de33451925534a8eb80c5e24f6db829d32a2699 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2015 The Weave Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef LIBWEAVE_SRC_PRIVET_PUBLISHER_H_
#define LIBWEAVE_SRC_PRIVET_PUBLISHER_H_

#include <memory>
#include <string>
#include <vector>

#include <base/macros.h>

namespace weave {

namespace provider {
class DnsServiceDiscovery;
}

namespace privet {

class CloudDelegate;
class DeviceDelegate;
class WifiDelegate;

// Publishes privet service on DNS-SD.
class Publisher {
 public:
  Publisher(const DeviceDelegate* device,
            const CloudDelegate* cloud,
            const WifiDelegate* wifi,
            provider::DnsServiceDiscovery* dns_sd);
  ~Publisher();

  // Updates published information.  Removes service if HTTP is not alive.
  void Update();

 private:
  void ExposeService();
  void RemoveService();

  provider::DnsServiceDiscovery* dns_sd_{nullptr};

  const DeviceDelegate* device_{nullptr};
  const CloudDelegate* cloud_{nullptr};
  const WifiDelegate* wifi_{nullptr};

  std::pair<uint16_t, std::vector<std::string>> published_;

  DISALLOW_COPY_AND_ASSIGN(Publisher);
};

}  // namespace privet
}  // namespace weave

#endif  // LIBWEAVE_SRC_PRIVET_PUBLISHER_H_