@@ -16,9 +16,26 @@ class ViamChannel {
1616 public:
1717 void close ();
1818 ViamChannel (std::shared_ptr<GrpcChannel> channel, const char * path, void * runtime);
19+
20+ // / @brief Connects to a robot at the given URI address, using the provided dial options (or
21+ // / default options is none are provided). Ignores initial connection options specifying
22+ // / how many times to attempt to connect and with what timeout.
23+ // / In general, use of this method is discouraged. `RobotClient::at_address(...)` is the
24+ // / preferred method to connect to a robot, and creates the channel itself.
25+ // / @throws Exception if it is unable to establish a connection to the provided URI
1926 static std::shared_ptr<ViamChannel> dial (const char * uri,
2027 const boost::optional<DialOptions>& options);
2128
29+ // @brief Dials to a robot at the given URI address, using the provided dial options (or default
30+ // options is none are provided). Additionally specifies that this dial is an initial connection
31+ // attempt and so uses the initial connection options.
32+ // / In general, use of this method is discouraged. `RobotClient::at_address(...)` is the
33+ // / preferred method to connect to a robot, and creates the channel itself.
34+ // / @throws Exception if it is unable to establish a connection to the provided URI within
35+ // / the given number of initial connection attempts
36+ static std::shared_ptr<ViamChannel> dial_initial (const char * uri,
37+ const boost::optional<DialOptions>& options);
38+
2239 const std::shared_ptr<GrpcChannel>& channel () const ;
2340
2441 private:
@@ -49,11 +66,15 @@ class DialOptions {
4966 const boost::optional<std::string>& entity () const ;
5067 bool allows_insecure_downgrade () const ;
5168 const std::chrono::duration<float >& timeout () const ;
69+ int initial_connection_attempts () const ;
70+ std::chrono::duration<float > initial_connection_attempt_timeout () const ;
5271
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);
72+ DialOptions& set_entity (boost::optional<std::string> entity);
73+ DialOptions& set_credentials (boost::optional<Credentials> creds);
74+ DialOptions& set_allow_insecure_downgrade (bool allow);
75+ DialOptions& set_timeout (std::chrono::duration<float > timeout);
76+ DialOptions& set_initial_connection_attempts (int attempts);
77+ DialOptions& set_initial_connection_attempt_timeout (std::chrono::duration<float > timeout);
5778
5879 private:
5980 // TODO (RSDK-917): We currently don't provide a flag for disabling webRTC, instead relying on a
@@ -72,6 +93,14 @@ class DialOptions {
7293 // / @brief Duration before the dial connection times out
7394 // / Set to 20sec to match _defaultOfferDeadline in goutils/rpc/wrtc_call_queue.go
7495 std::chrono::duration<float > timeout_{20 };
96+
97+ // / @brief Number of attempts to make when initially connecting to a robot
98+ // / If set to 0 or a negative integer, will attempt to reconnect forever.
99+ int initial_connection_attempts_ = 3 ;
100+
101+ // / @brief Timeout of connection attempts when initially dialing a robot
102+ // / Defaults to 20sec to match the default timeout duration
103+ std::chrono::duration<float > initial_connection_attempt_timeout_{20 };
75104};
76105
77106class Options {
0 commit comments