void AsyncFizzClientT::ActionMoveVisitor::operator()

in fizz/client/AsyncFizzClient-inl.h [500:558]


void AsyncFizzClientT<SM>::ActionMoveVisitor::operator()(
    ReportHandshakeSuccess& success) {
  client_.cancelHandshakeTimeout();

  // Disable record aligned reads. At this point, we are aligned on a record
  // boundary (if handshakeRecordAlignedReads = true).
  client_.updateReadHint(0);

  // if there are app writes pending this handshake success, flush them first,
  // then flush the early data buffers
  auto& pendingHandshakeAppWrites = client_.pendingHandshakeAppWrites_;
  while (!pendingHandshakeAppWrites.empty()) {
    auto w = std::move(pendingHandshakeAppWrites.front());
    pendingHandshakeAppWrites.pop_front();
    client_.fizzClient_.appWrite(std::move(w));
  }

  if (client_.earlyDataState_) {
    if (!success.earlyDataAccepted) {
      auto ex = client_.handleEarlyReject();
      if (ex) {
        if (client_.pskIdentity_) {
          client_.fizzContext_->removePsk(*client_.pskIdentity_);
        }
        client_.deliverAllErrors(*ex, false);
        client_.transport_->closeNow();
        return;
      }
    }

    while (!client_.earlyDataState_->pendingAppWrites.empty()) {
      auto w = std::move(client_.earlyDataState_->pendingAppWrites.front());
      client_.earlyDataState_->pendingAppWrites.pop_front();
      client_.fizzClient_.appWrite(std::move(w));
    }
    client_.earlyDataState_.clear();
  }
  if (client_.callback_) {
    auto cb = client_.callback_;
    client_.callback_ = folly::none;
    switch (cb->type()) {
      case AsyncClientCallbackPtr::Type::HandshakeCallback:
        if (cb->asHandshakeCallbackPtr()) {
          cb->asHandshakeCallbackPtr()->fizzHandshakeSuccess(&client_);
        }
        break;
      case AsyncClientCallbackPtr::Type::AsyncSocketConnCallback:
        if (cb->asAsyncSocketConnCallbackPtr()) {
          cb->asAsyncSocketConnCallbackPtr()->connectSuccess();
        }
        break;
    }
  }
  if (client_.replaySafetyCallback_) {
    auto callback = client_.replaySafetyCallback_;
    client_.replaySafetyCallback_ = nullptr;
    callback->onReplaySafe();
  }
}