// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #pragma once #include "td/mtproto/Handshake.h" #include "td/mtproto/HandshakeConnection.h" #include "td/mtproto/RawConnection.h" #include "td/actor/actor.h" #include "td/actor/PromiseFuture.h" #include "td/utils/Status.h" namespace td { namespace mtproto { // Owns RawConnection. Generates new auth key. And returns it and RawConnection. Or error... class HandshakeActor final : public Actor { public: HandshakeActor(unique_ptr handshake, unique_ptr raw_connection, unique_ptr context, double timeout, Promise> raw_connection_promise, Promise> handshake_promise); void close(); private: unique_ptr handshake_; unique_ptr connection_; double timeout_; Promise> raw_connection_promise_; Promise> handshake_promise_; void start_up() final; void tear_down() final; void hangup() final; void timeout_expired() final; void loop() final; void finish(Status status); void return_connection(Status status); void return_handshake(); }; } // namespace mtproto } // namespace td