@@ -1208,7 +1208,7 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
1208
1208
>* = nullptr
1209
1209
>
1210
1210
auto async_connect (CompletionToken&& token) {
1211
- return async_connect (any (), token);
1211
+ return async_connect (any (), std::forward<CompletionToken>( token) );
1212
1212
}
1213
1213
1214
1214
/* *
@@ -1228,7 +1228,7 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
1228
1228
async_connect (
1229
1229
v5::properties{},
1230
1230
force_move (session_life_keeper),
1231
- token
1231
+ std::forward<CompletionToken>( token)
1232
1232
);
1233
1233
}
1234
1234
@@ -1265,7 +1265,7 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
1265
1265
>* = nullptr
1266
1266
>
1267
1267
auto async_connect (v5::properties props, CompletionToken&& token) {
1268
- return async_connect (force_move (props), any (), token);
1268
+ return async_connect (force_move (props), any (), std::forward<CompletionToken>( token) );
1269
1269
}
1270
1270
1271
1271
/* *
@@ -1344,7 +1344,7 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
1344
1344
async_connect (
1345
1345
force_move (socket),
1346
1346
v5::properties{}, any (),
1347
- token
1347
+ std::forward<CompletionToken>( token)
1348
1348
);
1349
1349
}
1350
1350
@@ -1368,7 +1368,7 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
1368
1368
force_move (socket),
1369
1369
v5::properties{},
1370
1370
force_move (session_life_keeper),
1371
- token
1371
+ std::forward<CompletionToken>( token)
1372
1372
);
1373
1373
}
1374
1374
@@ -1427,7 +1427,7 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
1427
1427
force_move (socket),
1428
1428
force_move (props),
1429
1429
any (),
1430
- token
1430
+ std::forward<CompletionToken>( token)
1431
1431
);
1432
1432
}
1433
1433
@@ -1586,7 +1586,7 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
1586
1586
base::async_disconnect (
1587
1587
reason_code,
1588
1588
force_move (props),
1589
- token
1589
+ std::forward<CompletionToken>( token)
1590
1590
);
1591
1591
}
1592
1592
@@ -1622,7 +1622,7 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
1622
1622
base::async_disconnect (
1623
1623
reason_code,
1624
1624
force_move (props),
1625
- token
1625
+ std::forward<CompletionToken>( token)
1626
1626
);
1627
1627
}
1628
1628
@@ -1663,7 +1663,7 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
1663
1663
);
1664
1664
return
1665
1665
base::async_disconnect (
1666
- token
1666
+ std::forward<CompletionToken>( token)
1667
1667
);
1668
1668
}
1669
1669
@@ -1962,9 +1962,11 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
1962
1962
) {
1963
1963
BOOST_ASSERT (state == initiate);
1964
1964
state = resolve;
1965
- resolver.async_resolve (
1966
- cl.host_ ,
1967
- cl.port_ ,
1965
+ auto & a_cl{cl};
1966
+ auto & a_resolver{resolver};
1967
+ a_resolver.async_resolve (
1968
+ a_cl.host_ ,
1969
+ a_cl.port_ ,
1968
1970
force_move (self)
1969
1971
);
1970
1972
}
@@ -1989,13 +1991,14 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
1989
1991
async_start_session (force_move (self));
1990
1992
break ;
1991
1993
#if defined(MQTT_USE_WS)
1992
- case tls_ws_handshake_tls:
1994
+ case tls_ws_handshake_tls: {
1993
1995
state = tls_ws_handshake_ws;
1996
+ auto & socket = *cl.socket_ ;
1994
1997
async_ws_handshake_socket (
1995
- *cl. socket_ ,
1998
+ socket ,
1996
1999
force_move (self)
1997
2000
);
1998
- break ;
2001
+ } break ;
1999
2002
case tls_ws_handshake_ws:
2000
2003
async_start_session (force_move (self));
2001
2004
break ;
@@ -2025,8 +2028,9 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
2025
2028
}
2026
2029
else {
2027
2030
state = connect;
2031
+ auto & a_cl{cl};
2028
2032
as::async_connect (
2029
- cl .socket_ ->lowest_layer (), eps.begin (), eps.end (), force_move (self)
2033
+ a_cl .socket_ ->lowest_layer (), eps.begin (), eps.end (), force_move (self)
2030
2034
);
2031
2035
}
2032
2036
}
@@ -2046,8 +2050,9 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
2046
2050
if (cl.ping_duration_ != std::chrono::steady_clock::duration::zero ()) {
2047
2051
cl.set_timer ();
2048
2052
}
2053
+ auto & socket = *cl.socket_ ;
2049
2054
async_handshake_socket (
2050
- *cl. socket_ ,
2055
+ socket ,
2051
2056
force_move (self)
2052
2057
);
2053
2058
}
@@ -2067,9 +2072,10 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
2067
2072
ws_endpoint<as::ip::tcp::socket, Strand>& socket,
2068
2073
Self&& self) {
2069
2074
state = ws_handshake;
2075
+ auto & a_cl{cl};
2070
2076
socket.async_handshake (
2071
- cl .host_ ,
2072
- cl .path_ ,
2077
+ a_cl .host_ ,
2078
+ a_cl .path_ ,
2073
2079
force_move (self)
2074
2080
);
2075
2081
}
@@ -2107,9 +2113,10 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
2107
2113
ws_endpoint<tls::stream<as::ip::tcp::socket>, Strand>& socket,
2108
2114
Self&& self) {
2109
2115
state = tls_ws_handshake_ws;
2116
+ auto & a_cl{cl};
2110
2117
socket.async_handshake (
2111
- cl .host_ ,
2112
- cl .path_ ,
2118
+ a_cl .host_ ,
2119
+ a_cl .path_ ,
2113
2120
force_move (self)
2114
2121
);
2115
2122
}
@@ -2127,18 +2134,20 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
2127
2134
template <typename Self>
2128
2135
void async_start_session (Self&& self) {
2129
2136
state = complete;
2130
- cl.async_read_control_packet_type (force_move (session_life_keeper));
2137
+ auto & a_cl{cl};
2138
+ auto a_props = force_move (props);
2139
+ a_cl.async_read_control_packet_type (force_move (session_life_keeper));
2131
2140
// sync base::connect() refer to parameters only in the function.
2132
2141
// So they can be passed as view.
2133
- cl .base_async_connect (
2134
- buffer (string_view (static_cast <base const &>(cl ).get_client_id ())),
2135
- (cl .user_name_ ? buffer (string_view (cl .user_name_ .value ()))
2136
- : optional<buffer>() ),
2137
- ( cl .password_ ? buffer (string_view (cl .password_ .value ()))
2138
- : optional<buffer>() ),
2139
- cl .will_ ,
2140
- cl .keep_alive_sec_ ,
2141
- force_move (props ),
2142
+ a_cl .base_async_connect (
2143
+ buffer (string_view (static_cast <base const &>(a_cl ).get_client_id ())),
2144
+ (a_cl .user_name_ ? buffer (string_view (a_cl .user_name_ .value ()))
2145
+ : optional<buffer>() ),
2146
+ (a_cl .password_ ? buffer (string_view (a_cl .password_ .value ()))
2147
+ : optional<buffer>() ),
2148
+ a_cl .will_ ,
2149
+ a_cl .keep_alive_sec_ ,
2150
+ force_move (a_props ),
2142
2151
force_move (self)
2143
2152
);
2144
2153
}
0 commit comments