@@ -28,7 +28,6 @@ namespace Aws
28
28
void MqttConnection::s_onConnectionInterrupted (aws_mqtt_client_connection *, int errorCode, void *userData)
29
29
{
30
30
auto connWrapper = reinterpret_cast <MqttConnection *>(userData);
31
- connWrapper->m_connectionState = ConnectionState::Connecting;
32
31
if (connWrapper->OnConnectionInterrupted )
33
32
{
34
33
connWrapper->OnConnectionInterrupted (*connWrapper, errorCode);
@@ -42,7 +41,6 @@ namespace Aws
42
41
void *userData)
43
42
{
44
43
auto connWrapper = reinterpret_cast <MqttConnection *>(userData);
45
- connWrapper->m_connectionState = ConnectionState::Connected;
46
44
if (connWrapper->OnConnectionResumed )
47
45
{
48
46
connWrapper->OnConnectionResumed (*connWrapper, returnCode, sessionPresent);
@@ -57,16 +55,6 @@ namespace Aws
57
55
void *userData)
58
56
{
59
57
auto connWrapper = reinterpret_cast <MqttConnection *>(userData);
60
-
61
- if (returnCode == AWS_MQTT_CONNECT_ACCEPTED)
62
- {
63
- connWrapper->m_connectionState = ConnectionState::Connected;
64
- }
65
- else
66
- {
67
- connWrapper->m_connectionState = ConnectionState::Error;
68
- }
69
-
70
58
if (connWrapper->OnConnectionCompleted )
71
59
{
72
60
connWrapper->OnConnectionCompleted (*connWrapper, errorCode, returnCode, sessionPresent);
@@ -76,9 +64,6 @@ namespace Aws
76
64
void MqttConnection::s_onDisconnect (aws_mqtt_client_connection *, void *userData)
77
65
{
78
66
auto connWrapper = reinterpret_cast <MqttConnection *>(userData);
79
-
80
- connWrapper->m_connectionState = ConnectionState::Disconnected;
81
-
82
67
if (connWrapper->OnDisconnect )
83
68
{
84
69
connWrapper->OnDisconnect (*connWrapper);
@@ -242,17 +227,15 @@ namespace Aws
242
227
243
228
self->m_underlyingConnection = aws_mqtt_client_connection_new (self->m_owningClient );
244
229
245
- if (! self->m_underlyingConnection )
230
+ if (self->m_underlyingConnection )
246
231
{
247
- self->m_connectionState = ConnectionState::Error;
232
+ aws_mqtt_client_connection_set_connection_interruption_handlers (
233
+ self->m_underlyingConnection ,
234
+ MqttConnection::s_onConnectionInterrupted,
235
+ self,
236
+ MqttConnection::s_onConnectionResumed,
237
+ self);
248
238
}
249
-
250
- aws_mqtt_client_connection_set_connection_interruption_handlers (
251
- self->m_underlyingConnection ,
252
- MqttConnection::s_onConnectionInterrupted,
253
- self,
254
- MqttConnection::s_onConnectionResumed,
255
- self);
256
239
}
257
240
258
241
MqttConnection::MqttConnection (
@@ -261,7 +244,7 @@ namespace Aws
261
244
uint16_t port,
262
245
const Io::SocketOptions &socketOptions,
263
246
const Io::TlsConnectionOptions &tlsConnOptions) noexcept
264
- : m_owningClient(client), m_connectionState(ConnectionState::Init), m_useTls(true )
247
+ : m_owningClient(client), m_useTls(true )
265
248
{
266
249
s_connectionInit (this , hostName, port, socketOptions, &tlsConnOptions);
267
250
}
@@ -271,7 +254,7 @@ namespace Aws
271
254
const char *hostName,
272
255
uint16_t port,
273
256
const Io::SocketOptions &socketOptions) noexcept
274
- : m_owningClient(client), m_connectionState(ConnectionState::Init), m_useTls(false )
257
+ : m_owningClient(client), m_useTls(false )
275
258
{
276
259
s_connectionInit (this , hostName, port, socketOptions, nullptr );
277
260
}
@@ -340,7 +323,6 @@ namespace Aws
340
323
return false ;
341
324
}
342
325
343
- m_connectionState = ConnectionState::Connecting;
344
326
return true ;
345
327
}
346
328
0 commit comments