Skip to content

Commit ac3c07f

Browse files
committed
stream: Add transport_bottom() to get the outermost stream
1 parent 55ecd13 commit ac3c07f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

api/net/stream.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,23 @@ namespace net {
181181
**/
182182
virtual Stream* transport() noexcept = 0;
183183

184+
/** Recursively navigate to the transport stream at the bottom **/
185+
inline Stream* bottom_transport() noexcept;
186+
184187
virtual size_t serialize_to(void*) const = 0;
185188

186189
virtual ~Stream() = default;
187190
}; // < class Stream
191+
192+
inline Stream* Stream::bottom_transport() noexcept
193+
{
194+
Stream* stream = this;
195+
while (stream->transport() != nullptr) {
196+
stream = stream->transport();
197+
}
198+
return stream;
199+
}
200+
188201
} // < namespace net
189202

190203
#endif // < NET_STREAM_HPP

0 commit comments

Comments
 (0)