// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2020 // // 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/telegram/ChannelId.h" #include "td/telegram/InputGroupCallId.h" #include "td/telegram/td_api.h" #include "td/telegram/telegram_api.h" #include "td/actor/actor.h" #include "td/actor/PromiseFuture.h" #include namespace td { class Td; class GroupCallManager : public Actor { public: GroupCallManager(Td *td, ActorShared<> parent); GroupCallManager(const GroupCallManager &) = delete; GroupCallManager &operator=(const GroupCallManager &) = delete; GroupCallManager(GroupCallManager &&) = delete; GroupCallManager &operator=(GroupCallManager &&) = delete; ~GroupCallManager() override; void create_group_call(ChannelId channel_id, Promise &&promise); void join_group_call(InputGroupCallId group_call_id, td_api::object_ptr &&payload, int32 source, bool is_muted, Promise> &&promise); void leave_group_call(InputGroupCallId group_call_id, int32 source, Promise &&promise); void discard_group_call(InputGroupCallId group_call_id, Promise &&promise); void on_update_group_call(tl_object_ptr group_call_ptr); void process_join_group_call_response(InputGroupCallId group_call_id, uint64 generation, tl_object_ptr &&updates, Promise &&promise); private: struct GroupCall; struct PendingJoinRequest; void tear_down() override; void on_join_group_call_response(InputGroupCallId group_call_id, string json_response); void finish_join_group_call(InputGroupCallId group_call_id, uint64 generation, Status error); InputGroupCallId update_group_call(const tl_object_ptr &group_call_ptr); static Result> get_group_call_join_response_object( string json_response); static tl_object_ptr get_update_group_call_object(InputGroupCallId group_call_id, const GroupCall *group_call); static tl_object_ptr get_group_call_object(InputGroupCallId group_call_id, const GroupCall *group_call); Td *td_; ActorShared<> parent_; std::unordered_map, InputGroupCallIdHash> group_calls_; std::unordered_map, InputGroupCallIdHash> pending_join_requests_; uint64 join_group_request_generation_ = 0; }; } // namespace td