roo_transport
API Documentation for roo_transport
Loading...
Searching...
No Matches
link.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "roo_io.h"
4
#include "roo_io/core/output_stream.h"
5
#include "
roo_transport.h
"
6
#include "
roo_transport/link/internal/thread_safe/channel.h
"
7
#include "
roo_transport/link/link_input_stream.h
"
8
#include "
roo_transport/link/link_output_stream.h
"
9
#include "
roo_transport/link/link_status.h
"
10
11
namespace
roo_transport
{
12
13
// Represents a reliable bidirectional peer-to-peer link over a packet-based
14
// transport.
15
class
Link
{
16
public
:
17
// Creates a dummy link in state kIdle.
18
// Use LinkTransport::connect() to create a proper connected link.
19
Link
();
20
21
Link
(
const
Link
&) =
delete
;
22
Link
&
operator=
(
const
Link
&) =
delete
;
23
24
// Support for move.
25
Link
(
Link
&& other);
26
27
// Support for move.
28
Link
&
operator=
(
Link
&& other);
29
30
// Obtains the input stream that can be used to read from the link.
31
LinkInputStream&
in
() {
return
in_; }
32
33
// Obtains the output stream that can be used to write to the link.
34
LinkOutputStream&
out
() {
return
out_; }
35
36
// Returns the current status of the link.
37
LinkStatus
status
()
const
;
38
39
// If the link is in state kConnecting, blocks until it becomes either
40
// kConnected or kBroken. Otherwise, returns immediately.
41
void
awaitConnected
();
42
43
// If the link is kIdle, kConnected, or kBroken, does nothing and returns
44
// true immediately. Otherwise (when the link is in state kConnecting), blocks
45
// until it becomes either kConnected or kBroken, or until the specified
46
// timeout elapses, and returns true if the link has changed state, and false
47
// if the timeout has elapsed.
48
bool
awaitConnected
(roo_time::Duration timeout);
49
50
// Disconnects the link, immediately bringing it to the idle state. If the
51
// link is already idle, does nothing.
52
void
disconnect
();
53
54
// Returns the ID that identifies this link. The link objects created by
55
// LinkTransport::connect() will have unique stream IDs.
56
uint32_t
streamId
()
const
{
return
my_stream_id_; }
57
58
private
:
59
friend
class
LinkStream
;
60
friend
class
LinkTransport
;
61
62
Link
(Channel& channel, uint32_t my_stream_id);
63
64
Channel* channel_;
65
uint32_t my_stream_id_;
66
LinkInputStream in_;
67
LinkOutputStream out_;
68
};
69
70
}
// namespace roo_transport
channel.h
roo_transport::LinkTransport
Definition
link_transport.h:12
roo_transport::Link
Definition
link.h:15
roo_transport::Link::Link
Link(const Link &)=delete
roo_transport::Link::disconnect
void disconnect()
Definition
link.cpp:53
roo_transport::Link::out
LinkOutputStream & out()
Definition
link.h:34
roo_transport::Link::awaitConnected
void awaitConnected()
Definition
link.cpp:43
roo_transport::Link::in
LinkInputStream & in()
Definition
link.h:31
roo_transport::Link::status
LinkStatus status() const
Definition
link.cpp:38
roo_transport::Link::streamId
uint32_t streamId() const
Definition
link.h:56
roo_transport::Link::Link
Link()
Definition
link.cpp:5
roo_transport::Link::LinkStream
friend class LinkStream
Definition
link.h:59
roo_transport::Link::operator=
Link & operator=(const Link &)=delete
link_input_stream.h
link_output_stream.h
link_status.h
roo_transport
Definition
in_buffer.h:8
roo_transport::LinkStatus
LinkStatus
Definition
link_status.h:5
roo_transport.h
temp_repos
roo_transport
src
roo_transport
link
link.h
Generated by
1.9.8