Async 1.7.0
AsyncTcpPrioClient.h
Go to the documentation of this file.
1
31#ifndef ASYNC_TCP_PRIO_CLIENT_INCLUDED
32#define ASYNC_TCP_PRIO_CLIENT_INCLUDED
33
34
35/****************************************************************************
36 *
37 * System Includes
38 *
39 ****************************************************************************/
40
41#include <cassert>
42
43
44/****************************************************************************
45 *
46 * Project Includes
47 *
48 ****************************************************************************/
49
50#include <AsyncTcpClient.h>
52#include <AsyncDnsLookup.h>
53#include <AsyncTimer.h>
54#include <AsyncApplication.h>
55
56
57/****************************************************************************
58 *
59 * Local Includes
60 *
61 ****************************************************************************/
62
63
64
65/****************************************************************************
66 *
67 * Forward declarations
68 *
69 ****************************************************************************/
70
71
72
73/****************************************************************************
74 *
75 * Namespace
76 *
77 ****************************************************************************/
78
79namespace Async
80{
81
82
83/****************************************************************************
84 *
85 * Forward declarations of classes inside of the declared namespace
86 *
87 ****************************************************************************/
88
89
90
91/****************************************************************************
92 *
93 * Defines & typedefs
94 *
95 ****************************************************************************/
96
97
98
99/****************************************************************************
100 *
101 * Exported Global Variables
102 *
103 ****************************************************************************/
104
105
106
107/****************************************************************************
108 *
109 * Class definitions
110 *
111 ****************************************************************************/
112
122template <typename ConT=TcpConnection>
123class TcpPrioClient : public ConT, public TcpPrioClientBase
124{
125 public:
136 explicit TcpPrioClient(size_t recv_buf_len = ConT::DEFAULT_RECV_BUF_LEN)
137 : ConT(recv_buf_len), TcpPrioClientBase(this)
138 {
139 initialize();
140 }
141
145 TcpPrioClient(const TcpPrioClient&) = delete;
146
151
155 virtual ~TcpPrioClient(void) {}
156
164 virtual void disconnect(void)
165 {
166 //std::cout << "### TcpPrioClient::disconnect" << std::endl;
168 }
169
178 //void markAsFailedConnect(void)
179 //{
180 // //std::cout << "### TcpPrioClient::markAsFailedConnect" << std::endl;
181 // m_successful_connect = false;
182 //}
183
184 protected:
185 using ConT::operator=;
186 using TcpPrioClientBase::operator=;
187
194 virtual void closeConnection(void)
195 {
196 ConT::closeConnection();
198 }
199
207 {
208 //std::cout << "### TcpPrioClient::onDisconnected:"
209 // //<< " m_successful_connect=" << m_successful_connect
210 // << std::endl;
211 ConT::onDisconnected(reason);
213 }
214
225 {
226 return new TcpClient<ConT>;
227 }
228
230 {
231 ConT::emitDisconnected(reason);
232 }
233
234 private:
235 //bool m_successful_connect = false;
236
238 {
239 //std::cout << "### TcpPrioClient::operator=(TcpClient<ConT>&&)" << std::endl;
240 *static_cast<TcpClientBase*>(this) =
241 std::move(*static_cast<TcpClientBase*>(&other));
242 return *this;
243 }
244}; /* class TcpPrioClient */
245
246
247} /* namespace Async */
248
249#endif /* ASYNC_TCP_PRIO_CLIENT_INCLUDED */
250
251/*
252 * This file has not been truncated
253 */
The core class for writing asyncronous applications.
Contains a class for executing DNS queries.
Contains a class for creating TCP client connections.
Contains a base class for creating prioritized TCP client connections.
Contains a single shot or periodic timer that emits a signal on timeout.
A base class for creating a TCP client connection.
virtual void closeConnection(void)
Disconnect from the remote peer.
A class for creating a TCP client connection.
DisconnectReason
Reason code for disconnects.
A base class for creating a prio controlled TCP client connection.
virtual void disconnect(void)
Disconnect from the remote host.
void initialize(void)
Must be called from the inheriting class constructor.
virtual void onDisconnected(TcpConnection::DisconnectReason reason)
Called when a connection has been terminated.
A_brief_class_description.
virtual void disconnect(void)
Disconnect from the remote host.
virtual void onDisconnected(TcpConnection::DisconnectReason reason)
Called when a connection has been terminated.
virtual ~TcpPrioClient(void)
Destructor.
TcpPrioClient & operator=(const TcpPrioClient &)=delete
Disallow copy assignment.
TcpPrioClient(const TcpPrioClient &)=delete
Disallow copy construction.
TcpPrioClient(size_t recv_buf_len=ConT::DEFAULT_RECV_BUF_LEN)
Constructor.
virtual void emitDisconnected(TcpConnection::DisconnectReason reason)
Emit the disconnected signal.
virtual void closeConnection(void)
Disconnect from the remote peer.
virtual TcpClientBase * newTcpClient(void)
Allocate a new TcpClient object.
Namespace for the asynchronous programming classes.