Async 1.7.0
AsyncTcpPrioClientBase.h
Go to the documentation of this file.
1
29
30#ifndef ASYNC_TCP_PRIO_CLIENT_BASE_INCLUDED
31#define ASYNC_TCP_PRIO_CLIENT_BASE_INCLUDED
32
33
34/****************************************************************************
35 *
36 * System Includes
37 *
38 ****************************************************************************/
39
40
41
42/****************************************************************************
43 *
44 * Project Includes
45 *
46 ****************************************************************************/
47
48#include <AsyncTcpClientBase.h>
49#include <AsyncDnsLookup.h>
50#include <AsyncTimer.h>
51
52
53/****************************************************************************
54 *
55 * Local Includes
56 *
57 ****************************************************************************/
58
59
60
61/****************************************************************************
62 *
63 * Forward declarations
64 *
65 ****************************************************************************/
66
67
68
69/****************************************************************************
70 *
71 * Namespace
72 *
73 ****************************************************************************/
74
75namespace Async
76{
77
78/****************************************************************************
79 *
80 * Forward declarations of classes inside of the declared namespace
81 *
82 ****************************************************************************/
83
84
85
86/****************************************************************************
87 *
88 * Defines & typedefs
89 *
90 ****************************************************************************/
91
92
93
94/****************************************************************************
95 *
96 * Exported Global Variables
97 *
98 ****************************************************************************/
99
100
101
102/****************************************************************************
103 *
104 * Class definitions
105 *
106 ****************************************************************************/
107
117{
118 public:
130
134 TcpPrioClientBase(TcpConnection *con, const std::string& remote_host,
135 uint16_t remote_port) = delete;
136
141 uint16_t remote_port) = delete;
142
146 virtual ~TcpPrioClientBase(void);
147
152 void setReconnectMinTime(unsigned t);
153
158 void setReconnectMaxTime(unsigned t);
159
165
171
184 void setService(const std::string& srv_name, const std::string& srv_proto,
185 const std::string& srv_domain);
186
220
229 const std::string& service(void) const;
230
239 void connect(void);
240
244 void connect(const std::string &remote_host,
245 uint16_t remote_port) = delete;
246
250 void connect(const Async::IpAddress& remote_ip,
251 uint16_t remote_port) = delete;
252
260 virtual void disconnect(void);
261
268 bool isIdle(void) const;
269
270 bool isPrimary(void) const;
271
272 using TcpClientBase::operator=;
273
274 protected:
284 void initialize(void);
285
293 virtual void connectionEstablished(void) override;
294
302
312 virtual TcpClientBase *newTcpClient(void) = 0;
313
319
320 private:
321 class Machine;
322 Machine* m_machine = nullptr;
323
324}; /* class TcpPrioClientBase */
325
326
327} /* namespace */
328
329#endif /* ASYNC_TCP_PRIO_CLIENT_BASE_INCLUDED */
330
331
332
333/*
334 * This file has not been truncated
335 */
336
Contains a class for executing DNS queries.
Contains a base class for creating TCP client connections.
Contains a single shot or periodic timer that emits a signal on timeout.
A class for representing an IP address in an OS independent way.
TcpClientBase(TcpConnection *con)
Constructor.
A class for handling exiting TCP connections.
DisconnectReason
Reason code for disconnects.
const std::string & service(void) const
Get the full service name.
virtual void connectionEstablished(void) override
Called when the connection has been established to the server.
virtual ~TcpPrioClientBase(void)
Destructor.
void connect(void)
Connect to the remote host.
bool isPrimary(void) const
virtual void disconnect(void)
Disconnect from the remote host.
void initialize(void)
Must be called from the inheriting class constructor.
void setService(const std::string &srv_name, const std::string &srv_proto, const std::string &srv_domain)
Use a DNS service resource record for connections.
TcpPrioClientBase(TcpConnection *con, const IpAddress &remote_ip, uint16_t remote_port)=delete
Deleted constructor not making sense in this context.
TcpPrioClientBase(TcpConnection *con, const std::string &remote_host, uint16_t remote_port)=delete
Deleted constructor not making sense in this context.
void setReconnectBackoffPercent(unsigned p)
Percent to increase reconnect time with each try.
void connect(const Async::IpAddress &remote_ip, uint16_t remote_port)=delete
Deleted function not making sense in this context.
void setReconnectMinTime(unsigned t)
Minimum time between reconnects.
void connect(const std::string &remote_host, uint16_t remote_port)=delete
Deleted function not making sense in this context.
void addStaticSRVRecord(DnsResourceRecordSRV::Ttl ttl, DnsResourceRecordSRV::Prio prio, DnsResourceRecordSRV::Weight weight, DnsResourceRecordSRV::Port port, DnsResourceRecordSRV::Target target)
Add a static service resource record.
TcpPrioClientBase(TcpConnection *con)
Constructor.
virtual void onDisconnected(TcpConnection::DisconnectReason reason)
Called when a connection has been terminated.
void setReconnectRandomizePercent(unsigned p)
Percent to randomize reconnect time.
virtual void emitDisconnected(TcpConnection::DisconnectReason reason)=0
Emit the disconnected signal.
void setReconnectMaxTime(unsigned t)
Maximum time between reconnects.
bool isIdle(void) const
Check if the connection is idle.
virtual TcpClientBase * newTcpClient(void)=0
Allocate a new TcpClient object.
Namespace for the asynchronous programming classes.