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