8 #ifndef WPIUTIL_WPI_UV_NETWORKSTREAM_H_
9 #define WPIUTIL_WPI_UV_NETWORKSTREAM_H_
16 #include "wpi/Signal.h"
17 #include "wpi/uv/Stream.h"
48 static constexpr
int kDefaultBacklog = 128;
50 std::shared_ptr<NetworkStream> shared_from_this() {
51 return std::static_pointer_cast<
NetworkStream>(Handle::shared_from_this());
54 std::shared_ptr<const NetworkStream> shared_from_this()
const {
56 Handle::shared_from_this());
65 void Listen(
int backlog = kDefaultBacklog);
77 void Listen(std::function<
void()> callback,
int backlog = kDefaultBacklog);
94 std::shared_ptr<NetworkStream>
Accept() {
95 return DoAccept()->shared_from_this();
114 bool Accept(
const std::shared_ptr<NetworkStream>& client) {
115 return Invoke(&uv_accept,
GetRawStream(), client->GetRawStream());
129 template <
typename T,
typename U>
132 std::shared_ptr<T> shared_from_this() {
133 return std::static_pointer_cast<T>(Handle::shared_from_this());
136 std::shared_ptr<const T> shared_from_this()
const {
137 return std::static_pointer_cast<
const T>(Handle::shared_from_this());
156 #endif // WPIUTIL_WPI_UV_NETWORKSTREAM_H_
Definition: NetworkStream.h:17
std::shared_ptr< NetworkStream > Accept()
Accept incoming connection.
Definition: NetworkStream.h:94
bool Accept(const std::shared_ptr< NetworkStream > &client)
Accept incoming connection.
Definition: NetworkStream.h:114
U * GetRaw() const noexcept
Get the underlying handle data structure.
Definition: NetworkStream.h:145
WPILib C++ utilities (wpiutil) namespace.
Definition: SmallString.h:21
Stream handle.
Definition: Stream.h:68
uv_connect_t * GetRaw() noexcept
Get the underlying request data structure.
Definition: Request.h:149
Definition: NetworkStream.h:130
sig::Signal connection
Signal generated when an incoming connection is received.
Definition: NetworkStream.h:121
Network stream handle.
Definition: NetworkStream.h:46
uv_stream_t * GetRawStream() const noexcept
Get the underlying stream data structure.
Definition: Stream.h:205
void Listen(int backlog=kDefaultBacklog)
Start listening for incoming connections.
Connection request.
Definition: NetworkStream.h:27
sig::Signal connected
Connection completed signal.
Definition: NetworkStream.h:38
SignalBase is an implementation of the observer pattern, through the use of an emitting object and sl...
Definition: Signal.h:495
Request.
Definition: Request.h:134
uv_handle_t * GetRawHandle() const noexcept
Get the underlying handle data structure.
Definition: Handle.h:155