Viam C++ SDK current
Loading...
Searching...
No Matches
dial.hpp
1#pragma once
2
3#include <memory>
4#include <string>
5
6#include <boost/optional.hpp>
7#include <grpcpp/channel.h>
8
9namespace viam {
10namespace sdk {
11
12class DialOptions;
14 public:
15 void close();
16 ViamChannel(std::shared_ptr<grpc::Channel> channel, const char* path, void* runtime);
17 static std::shared_ptr<ViamChannel> dial(const char* uri,
18 const boost::optional<DialOptions>& options);
19
20 const std::shared_ptr<grpc::Channel>& channel() const;
21
22 private:
23 std::shared_ptr<grpc::Channel> channel_;
24 const char* path_;
25 bool closed_;
26 void* rust_runtime_;
27};
28
30 public:
32 Credentials(std::string payload);
33 Credentials(std::string type, std::string payload);
34 const std::string& type() const;
35 const std::string& payload() const;
36
37 private:
38 std::string type_;
39 std::string payload_;
40};
41
43 public:
45
46 const boost::optional<Credentials>& credentials() const;
47 const boost::optional<std::string>& entity() const;
48 bool allows_insecure_downgrade() const;
49 const std::chrono::duration<float>& timeout() const;
50
51 void set_entity(boost::optional<std::string> entity);
52 void set_credentials(boost::optional<Credentials> creds);
53 void set_allow_insecure_downgrade(bool allow);
54 void set_timeout(std::chrono::duration<float> timeout);
55
56 private:
57 // TODO (RSDK-917): We currently don't provide a flag for disabling webRTC, instead relying on a
58 // `local` uri. We should update dial logic to consider such a flag.
59
61 boost::optional<std::string> auth_entity_;
62
64 boost::optional<Credentials> credentials_;
65
68 bool allow_insecure_downgrade_ = false;
69
72 std::chrono::duration<float> timeout_{20};
73};
74
75class Options {
76 public:
77 Options(unsigned int refresh_interval, boost::optional<DialOptions> dial_options)
78 : refresh_interval_(std::move(refresh_interval)), dial_options_(std::move(dial_options)) {}
79
80 unsigned int refresh_interval() const;
81 const boost::optional<DialOptions>& dial_options() const;
82
83 private:
86 unsigned int refresh_interval_;
87 boost::optional<DialOptions> dial_options_;
88};
89
90} // namespace sdk
91} // namespace viam
Definition dial.hpp:29
Credentials(std::string payload)
Definition dial.hpp:42
Definition dial.hpp:75
Definition dial.hpp:13