| 267 | |
| 268 | Result HttpAsyncClient::closeConnectionForReconnect() |
| 269 | { |
| 270 | reconnectPending = true; |
| 271 | state = State::Connecting; |
| 272 | |
| 273 | if (transportShutdown.isValid()) |
| 274 | { |
| 275 | Function<void(Result)> complete = {[this](Result result) { onReconnectTransportShutdown(result); }}; |
| 276 | Result shutdown = transportShutdown(move(complete)); |
| 277 | if (not shutdown) |
| 278 | { |
| 279 | reconnectPending = false; |
| 280 | state = State::Idle; |
| 281 | } |
| 282 | return shutdown; |
| 283 | } |
| 284 | return beginReconnectClose(); |
| 285 | } |
| 286 | |
| 287 | Result HttpAsyncClient::beginReconnectClose() |
| 288 | { |
| 289 | if (not reconnectPending) |
| 290 | return Result::Error(HttpResultCategory, HttpError::ClientReconnectNotPending); |
| 291 | reconnectCloseInProgress = true; |
| 292 | reconnectClosuresPending = 0; |
| 293 | |
| 294 | reconnectReadableStream = &connection->getReadableTransportStream(); |
| 295 | reconnectWritableStream = &connection->getWritableTransportStream(); |
| 296 | reconnectSocketReadableStream = |
| 297 | reconnectReadableStream != &connection->readableSocketStream ? &connection->readableSocketStream : nullptr; |
| 298 | reconnectSocketWritableStream = |
| 299 | reconnectWritableStream != &connection->writableSocketStream ? &connection->writableSocketStream : nullptr; |
| 300 | |
| 301 | if (not reconnectReadableStream->hasBeenDestroyed()) |
| 302 | { |
| 303 | const bool added = reconnectReadableStream->eventClose |
| 304 | .addListener<HttpAsyncClient, &HttpAsyncClient::onReconnectReadableClosed>(*this); |
| 305 | if (not added) |
| 306 | { |
| 307 | clearReconnectCloseListeners(); |
| 308 | return Result::Error(HttpResultCategory, HttpError::ClientReconnectListenerUnavailable); |
| 309 | } |
| 310 | reconnectClosuresPending++; |
| 311 | } |
nothing calls this directly
no test coverage detected