Async 1.8.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
142 TcpPrioClient(const TcpPrioClient&) = delete;
143
148
152 virtual ~TcpPrioClient(void) {}
153
161 virtual void disconnect(void)
162 {
163 //std::cout << "### TcpPrioClient::disconnect" << std::endl;
165 }
166
167 protected:
168 using ConT::operator=;
169 using TcpPrioClientBase::operator=;
170
177 virtual void closeConnection(void)
178 {
179 ConT::closeConnection();
181 }
182
190 {
191 //std::cout << "### TcpPrioClient::onDisconnected:"
192 // << std::endl;
193 ConT::onDisconnected(reason);
195 }
196
206 virtual TcpClientBase* newTcpClient(void) override
207 {
208 return new TcpClient<ConT>;
209 }
210
212 {
213 ConT::emitDisconnected(reason);
214 }
215
216 private:
218 {
219 //std::cout << "### TcpPrioClient::operator=(TcpClient<ConT>&&)"
220 // << std::endl;
221 *static_cast<TcpClientBase*>(this) =
222 std::move(*static_cast<TcpClientBase*>(&other));
223 return *this;
224 }
225}; /* class TcpPrioClient */
226
227
228} /* namespace Async */
229
230#endif /* ASYNC_TCP_PRIO_CLIENT_INCLUDED */
231
232/*
233 * This file has not been truncated
234 */
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)
Check if the connection has been fully connected.
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.
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 TcpClientBase * newTcpClient(void) override
Allocate a new TcpClient object.
virtual void emitDisconnected(TcpConnection::DisconnectReason reason)
Emit the disconnected signal.
virtual void closeConnection(void)
Disconnect from the remote peer.
Namespace for the asynchronous programming classes.