43 :
public std::enable_shared_from_this<ParallelTcpConnector> {
44 struct private_init {};
61 static std::shared_ptr<ParallelTcpConnector>
Create(
64 bool ipv4Only =
false) {
68 return std::make_shared<ParallelTcpConnector>(loop, reconnectRate, logger,
70 ipv4Only, private_init{});
76 bool ipv4Only,
const private_init&);
94 std::span<
const std::pair<std::string, unsigned int>> servers);
111 bool IsConnected()
const {
return m_isConnected || m_servers.empty(); }
120 std::shared_ptr<wpi::uv::Timer> m_reconnectTimer;
121 std::vector<std::pair<std::string, unsigned int>> m_servers;
122 std::vector<std::weak_ptr<wpi::uv::GetAddrInfoReq>> m_resolvers;
123 std::vector<std::pair<sockaddr_storage, std::weak_ptr<wpi::uv::Tcp>>>
125 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, bool ipv4Only=false)
Create.
Definition ParallelTcpConnector.h:61
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, bool ipv4Only, 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
Foonathan namespace.
Definition ntcore_cpp.h:26