blob: 5de33451925534a8eb80c5e24f6db829d32a2699 [file] [log] [blame]
Vitaly Buka4615e0d2015-10-14 15:35:12 -07001// Copyright 2015 The Weave Authors. All rights reserved.
Vitaly Buka0bd32132015-07-30 15:54:48 -07002// 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 Buka8589b052015-09-29 00:46:14 -070010#include <vector>
Vitaly Buka0bd32132015-07-30 15:54:48 -070011
12#include <base/macros.h>
13
Vitaly Buka0bd32132015-07-30 15:54:48 -070014namespace weave {
15
Vitaly Buka1e363672015-09-25 14:01:16 -070016namespace provider {
17class DnsServiceDiscovery;
18}
Vitaly Buka0bd32132015-07-30 15:54:48 -070019
20namespace privet {
21
22class CloudDelegate;
23class DeviceDelegate;
24class WifiDelegate;
25
Vitaly Bukabeddc602015-09-24 15:28:03 -070026// Publishes privet service on DNS-SD.
Johan Euphrosine0b7bb9f2015-09-29 01:11:21 -070027class Publisher {
Vitaly Buka0bd32132015-07-30 15:54:48 -070028 public:
29 Publisher(const DeviceDelegate* device,
30 const CloudDelegate* cloud,
31 const WifiDelegate* wifi,
Vitaly Buka1e363672015-09-25 14:01:16 -070032 provider::DnsServiceDiscovery* dns_sd);
Johan Euphrosine0b7bb9f2015-09-29 01:11:21 -070033 ~Publisher();
Vitaly Buka0bd32132015-07-30 15:54:48 -070034
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 Buka1e363672015-09-25 14:01:16 -070042 provider::DnsServiceDiscovery* dns_sd_{nullptr};
Vitaly Buka0bd32132015-07-30 15:54:48 -070043
44 const DeviceDelegate* device_{nullptr};
45 const CloudDelegate* cloud_{nullptr};
46 const WifiDelegate* wifi_{nullptr};
47
Vitaly Buka8589b052015-09-29 00:46:14 -070048 std::pair<uint16_t, std::vector<std::string>> published_;
49
Vitaly Buka0bd32132015-07-30 15:54:48 -070050 DISALLOW_COPY_AND_ASSIGN(Publisher);
51};
52
53} // namespace privet
54} // namespace weave
55
56#endif // LIBWEAVE_SRC_PRIVET_PUBLISHER_H_