43 :
public std::enable_shared_from_this<ParallelTcpConnector> {
44 struct private_init {};
59 static std::shared_ptr<ParallelTcpConnector>
Create(
65 return std::make_shared<ParallelTcpConnector>(
66 loop, reconnectRate, logger, std::move(connected), private_init{});
90 std::span<
const std::pair<std::string, unsigned int>> servers);
107 bool IsConnected()
const {
return m_isConnected || m_servers.empty(); }
115 std::shared_ptr<wpi::uv::Timer> m_reconnectTimer;
116 std::vector<std::pair<std::string, unsigned int>> m_servers;
117 std::vector<std::weak_ptr<wpi::uv::GetAddrInfoReq>> m_resolvers;
118 std::vector<std::pair<sockaddr_storage, std::weak_ptr<wpi::uv::Tcp>>>
120 bool m_isConnected{
false};
Parallel TCP connector.
Definition: ParallelTcpConnector.h:43
void Close()
Closes resources, canceling all pending action attempts.
ParallelTcpConnector & operator=(const ParallelTcpConnector &)=delete
static std::shared_ptr< ParallelTcpConnector > Create(wpi::uv::Loop &loop, wpi::uv::Timer::Time reconnectRate, wpi::Logger &logger, std::function< void(wpi::uv::Tcp &tcp)> connected)
Create.
Definition: ParallelTcpConnector.h:59
void Succeeded(wpi::uv::Tcp &tcp)
Tells the parallel connector that a particular connection has succeeded and it should stop trying to ...
void Disconnected()
Tells the parallel connector that the current connection has terminated and it is necessary to start ...
void SetServers(std::span< const std::pair< std::string, unsigned int > > servers)
Changes the servers/ports to connect to.
ParallelTcpConnector(wpi::uv::Loop &loop, wpi::uv::Timer::Time reconnectRate, wpi::Logger &logger, std::function< void(wpi::uv::Tcp &tcp)> connected, const private_init &)
ParallelTcpConnector(const ParallelTcpConnector &)=delete
Event loop.
Definition: Loop.h:37
bool IsClosing() const
Return the loop closed flag.
Definition: Loop.h:85
TCP handle.
Definition: Tcp.h:27
std::chrono::duration< uint64_t, std::milli > Time
Definition: Timer.h:31
Definition: ntcore_cpp.h:26