@@ -131,7 +131,7 @@ void RobotClient::close() {
131131 should_refresh_.store (false );
132132 threads_.clear ();
133133 stop_all ();
134- viam_channel_-> close ();
134+ viam_channel_. close ();
135135}
136136
137137bool is_error_response (const grpc::Status& response) {
@@ -209,7 +209,7 @@ void RobotClient::refresh() {
209209 if (rs) {
210210 try {
211211 const std::shared_ptr<Resource> rpc_client =
212- rs->create_rpc_client (name.name (), channel_ );
212+ rs->create_rpc_client (name.name (), viam_channel_. channel () );
213213 const Name name_ ({name.namespace_ (), name.type (), name.subtype ()}, " " , name.name ());
214214 new_resources.emplace (name_, rpc_client);
215215 } catch (const std::exception& exc) {
@@ -248,11 +248,10 @@ void RobotClient::refresh_every() {
248248 }
249249};
250250
251- RobotClient::RobotClient (std::shared_ptr<ViamChannel> channel)
252- : channel_(channel->channel ()),
253- viam_channel_(std::move(channel)),
251+ RobotClient::RobotClient (ViamChannel channel)
252+ : viam_channel_(std::move(channel)),
254253 should_close_channel_ (false ),
255- impl_(std::make_unique<impl>(RobotService::NewStub(channel_ ))) {}
254+ impl_(std::make_unique<impl>(RobotService::NewStub(viam_channel_.channel() ))) {}
256255
257256std::vector<Name> RobotClient::resource_names () const {
258257 const std::lock_guard<std::mutex> lock (lock_);
@@ -284,9 +283,9 @@ void RobotClient::log(const std::string& name,
284283 }
285284}
286285
287- std::shared_ptr<RobotClient> RobotClient::with_channel (std::shared_ptr< ViamChannel> channel,
286+ std::shared_ptr<RobotClient> RobotClient::with_channel (ViamChannel channel,
288287 const Options& options) {
289- std::shared_ptr<RobotClient> robot = std::make_shared<RobotClient>(std::move (channel));
288+ auto robot = std::make_shared<RobotClient>(std::move (channel));
290289 robot->refresh_interval_ = options.refresh_interval ();
291290 robot->should_refresh_ = (robot->refresh_interval_ > 0 );
292291 if (robot->should_refresh_ ) {
@@ -305,8 +304,8 @@ std::shared_ptr<RobotClient> RobotClient::with_channel(std::shared_ptr<ViamChann
305304std::shared_ptr<RobotClient> RobotClient::at_address (const std::string& address,
306305 const Options& options) {
307306 const char * uri = address.c_str ();
308- auto channel = ViamChannel::dial_initial (uri, options. dial_options ());
309- std::shared_ptr<RobotClient> robot = RobotClient::with_channel (channel , options);
307+ std::shared_ptr<RobotClient> robot =
308+ RobotClient::with_channel (ViamChannel::dial_initial (uri, options. dial_options ()) , options);
310309 robot->should_close_channel_ = true ;
311310
312311 return robot;
@@ -315,10 +314,9 @@ std::shared_ptr<RobotClient> RobotClient::at_address(const std::string& address,
315314std::shared_ptr<RobotClient> RobotClient::at_local_socket (const std::string& address,
316315 const Options& options) {
317316 const std::string addr = " unix://" + address;
318- const std::shared_ptr<grpc::Channel> channel =
319- sdk::impl::create_viam_channel (addr, grpc::InsecureChannelCredentials ());
320- std::shared_ptr<RobotClient> robot =
321- RobotClient::with_channel (std::make_shared<ViamChannel>(channel), options);
317+ std::shared_ptr<RobotClient> robot = RobotClient::with_channel (
318+ ViamChannel (sdk::impl::create_viam_channel (addr, grpc::InsecureChannelCredentials ())),
319+ options);
322320 robot->should_close_channel_ = true ;
323321
324322 return robot;
0 commit comments