@@ -53,43 +53,43 @@ namespace Aws
53
53
54
54
SecureTunnelBuilder &SecureTunnelBuilder::WithOnConnectionComplete (OnConnectionComplete onConnectionComplete)
55
55
{
56
- m_OnConnectionComplete = onConnectionComplete;
56
+ m_OnConnectionComplete = std::move ( onConnectionComplete) ;
57
57
return *this ;
58
58
}
59
59
60
60
SecureTunnelBuilder &SecureTunnelBuilder::WithOnConnectionShutdown (OnConnectionShutdown onConnectionShutdown)
61
61
{
62
- m_OnConnectionShutdown = onConnectionShutdown;
62
+ m_OnConnectionShutdown = std::move ( onConnectionShutdown) ;
63
63
return *this ;
64
64
}
65
65
66
66
SecureTunnelBuilder &SecureTunnelBuilder::WithOnSendDataComplete (OnSendDataComplete onSendDataComplete)
67
67
{
68
- m_OnSendDataComplete = onSendDataComplete;
68
+ m_OnSendDataComplete = std::move ( onSendDataComplete) ;
69
69
return *this ;
70
70
}
71
71
72
72
SecureTunnelBuilder &SecureTunnelBuilder::WithOnDataReceive (OnDataReceive onDataReceive)
73
73
{
74
- m_OnDataReceive = onDataReceive;
74
+ m_OnDataReceive = std::move ( onDataReceive) ;
75
75
return *this ;
76
76
}
77
77
78
78
SecureTunnelBuilder &SecureTunnelBuilder::WithOnStreamStart (OnStreamStart onStreamStart)
79
79
{
80
- m_OnStreamStart = onStreamStart;
80
+ m_OnStreamStart = std::move ( onStreamStart) ;
81
81
return *this ;
82
82
}
83
83
84
84
SecureTunnelBuilder &SecureTunnelBuilder::WithOnStreamReset (OnStreamReset onStreamReset)
85
85
{
86
- m_OnStreamReset = onStreamReset;
86
+ m_OnStreamReset = std::move ( onStreamReset) ;
87
87
return *this ;
88
88
}
89
89
90
90
SecureTunnelBuilder &SecureTunnelBuilder::WithOnSessionReset (OnSessionReset onSessionReset)
91
91
{
92
- m_OnSessionReset = onSessionReset;
92
+ m_OnSessionReset = std::move ( onSessionReset) ;
93
93
return *this ;
94
94
}
95
95
@@ -144,13 +144,13 @@ namespace Aws
144
144
OnSessionReset onSessionReset)
145
145
{
146
146
// Client callbacks
147
- m_OnConnectionComplete = onConnectionComplete;
148
- m_OnConnectionShutdown = onConnectionShutdown;
149
- m_OnSendDataComplete = onSendDataComplete;
150
- m_OnDataReceive = onDataReceive;
151
- m_OnStreamStart = onStreamStart;
152
- m_OnStreamReset = onStreamReset;
153
- m_OnSessionReset = onSessionReset;
147
+ m_OnConnectionComplete = std::move ( onConnectionComplete) ;
148
+ m_OnConnectionShutdown = std::move ( onConnectionShutdown) ;
149
+ m_OnSendDataComplete = std::move ( onSendDataComplete) ;
150
+ m_OnDataReceive = std::move ( onDataReceive) ;
151
+ m_OnStreamStart = std::move ( onStreamStart) ;
152
+ m_OnStreamReset = std::move ( onStreamReset) ;
153
+ m_OnSessionReset = std::move ( onSessionReset) ;
154
154
155
155
// Initialize aws_secure_tunnel_options
156
156
aws_secure_tunnel_options config;
@@ -176,6 +176,7 @@ namespace Aws
176
176
config.on_stream_start = s_OnStreamStart;
177
177
config.on_stream_reset = s_OnStreamReset;
178
178
config.on_session_reset = s_OnSessionReset;
179
+ config.on_termination_complete = s_OnTerminationComplete;
179
180
180
181
config.user_data = this ;
181
182
@@ -272,13 +273,15 @@ namespace Aws
272
273
273
274
SecureTunnel::SecureTunnel (SecureTunnel &&other) noexcept
274
275
{
275
- m_OnConnectionComplete = other.m_OnConnectionComplete ;
276
- m_OnConnectionShutdown = other.m_OnConnectionShutdown ;
277
- m_OnSendDataComplete = other.m_OnSendDataComplete ;
278
- m_OnDataReceive = other.m_OnDataReceive ;
279
- m_OnStreamStart = other.m_OnStreamStart ;
280
- m_OnStreamReset = other.m_OnStreamReset ;
281
- m_OnSessionReset = other.m_OnSessionReset ;
276
+ m_OnConnectionComplete = std::move (other.m_OnConnectionComplete );
277
+ m_OnConnectionShutdown = std::move (other.m_OnConnectionShutdown );
278
+ m_OnSendDataComplete = std::move (other.m_OnSendDataComplete );
279
+ m_OnDataReceive = std::move (other.m_OnDataReceive );
280
+ m_OnStreamStart = std::move (other.m_OnStreamStart );
281
+ m_OnStreamReset = std::move (other.m_OnStreamReset );
282
+ m_OnSessionReset = std::move (other.m_OnSessionReset );
283
+
284
+ m_TerminationComplete = std::move (other.m_TerminationComplete );
282
285
283
286
m_secure_tunnel = other.m_secure_tunnel ;
284
287
@@ -299,13 +302,15 @@ namespace Aws
299
302
{
300
303
this ->~SecureTunnel ();
301
304
302
- m_OnConnectionComplete = other.m_OnConnectionComplete ;
303
- m_OnConnectionShutdown = other.m_OnConnectionShutdown ;
304
- m_OnSendDataComplete = other.m_OnSendDataComplete ;
305
- m_OnDataReceive = other.m_OnDataReceive ;
306
- m_OnStreamStart = other.m_OnStreamStart ;
307
- m_OnStreamReset = other.m_OnStreamReset ;
308
- m_OnSessionReset = other.m_OnSessionReset ;
305
+ m_OnConnectionComplete = std::move (other.m_OnConnectionComplete );
306
+ m_OnConnectionShutdown = std::move (other.m_OnConnectionShutdown );
307
+ m_OnSendDataComplete = std::move (other.m_OnSendDataComplete );
308
+ m_OnDataReceive = std::move (other.m_OnDataReceive );
309
+ m_OnStreamStart = std::move (other.m_OnStreamStart );
310
+ m_OnStreamReset = std::move (other.m_OnStreamReset );
311
+ m_OnSessionReset = std::move (other.m_OnSessionReset );
312
+
313
+ m_TerminationComplete = std::move (other.m_TerminationComplete );
309
314
310
315
m_secure_tunnel = other.m_secure_tunnel ;
311
316
@@ -395,5 +400,21 @@ namespace Aws
395
400
}
396
401
}
397
402
403
+ void SecureTunnel::s_OnTerminationComplete (void *user_data)
404
+ {
405
+ auto *secureTunnel = static_cast <SecureTunnel *>(user_data);
406
+ secureTunnel->OnTerminationComplete ();
407
+ }
408
+
409
+ void SecureTunnel::OnTerminationComplete () { m_TerminationComplete.set_value (); }
410
+
411
+ void SecureTunnel::Shutdown ()
412
+ {
413
+ Close ();
414
+ aws_secure_tunnel_release (m_secure_tunnel);
415
+ m_secure_tunnel = nullptr ;
416
+
417
+ m_TerminationComplete.get_future ().wait ();
418
+ }
398
419
} // namespace Iotsecuretunneling
399
420
} // namespace Aws
0 commit comments