roo_transport
API Documentation for roo_transport
Loading...
Searching...
No Matches
link.cpp
Go to the documentation of this file.
2
3namespace roo_transport {
4
5Link::Link() : channel_(nullptr), my_stream_id_(0) {}
6
7Link::Link(Channel& channel, uint32_t my_stream_id)
8 : channel_(&channel),
9 my_stream_id_(my_stream_id),
10 in_(*channel_, my_stream_id),
11 out_(*channel_, my_stream_id) {}
12
14 : channel_(other.channel_),
15 my_stream_id_(other.my_stream_id_),
16 in_(std::move(other.in_)),
17 out_(std::move(other.out_)) {
18 other.channel_ = nullptr;
19 other.my_stream_id_ = 0;
20 other.in_ = LinkInputStream();
21 other.out_ = LinkOutputStream();
22}
23
25 if (&other != this) {
26 channel_ = other.channel_;
27 my_stream_id_ = other.my_stream_id_;
28 in_ = std::move(other.in_);
29 out_ = std::move(other.out_);
30 other.channel_ = nullptr;
31 other.my_stream_id_ = 0;
32 other.in_ = LinkInputStream();
33 other.out_ = LinkOutputStream();
34 }
35 return *this;
36}
37
39 return channel_ == nullptr ? LinkStatus::kIdle
40 : channel_->getLinkStatus(my_stream_id_);
41}
42
44 if (channel_ == nullptr) return;
45 channel_->awaitConnected(my_stream_id_);
46}
47
48bool Link::awaitConnected(roo_time::Duration timeout) {
49 if (channel_ == nullptr) return true;
50 return channel_->awaitConnected(my_stream_id_, timeout);
51}
52
54 if (channel_ == nullptr) return;
55 channel_->disconnect(my_stream_id_);
56 channel_ = nullptr;
57}
58
59} // namespace roo_transport