Async 1.8.0
AsyncTcpPrioClientBase.h
Go to the documentation of this file.
1
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
276
280 bool markedAsEstablished(void) const;
281
288 bool isIdle(void) const;
289
293 bool isPrimary(void) const;
294
298 using TcpClientBase::operator=;
299
300 protected:
308 virtual void connectionEstablished(void) override;
309
317
327 virtual TcpClientBase *newTcpClient(void) = 0;
328
334
335 private:
336 class Machine;
337
338 Machine* machine(void) const;
339
340 mutable Machine* m_machine = nullptr;
341
342}; /* class TcpPrioClientBase */
343
344
345} /* namespace */
346
347#endif /* ASYNC_TCP_PRIO_CLIENT_BASE_INCLUDED */
348
349
350
351/*
352 * This file has not been truncated
353 */
354
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.
A base class for creating a TCP client connection.
A class for handling exiting TCP connections.
DisconnectReason
Reason code for disconnects.
A base class for creating a prio controlled TCP client connection.
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
Check if connected to the primary server.
virtual void disconnect(void)
Disconnect from the remote host.
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.
bool markedAsEstablished(void) const
Check if a connection has been marked as established.
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.
void markAsEstablished(void)
Mark connection as established.
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.