|
|
|
@ -112,13 +112,17 @@ void ClientManager::send(PromisedQueryPtr query) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
flood_control.add_event(static_cast<td::int32>(now));
|
|
|
|
flood_control.add_event(static_cast<td::int32>(now));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto tqueue_id = get_tqueue_id(r_user_id.ok(), query->is_test_dc());
|
|
|
|
|
|
|
|
if (active_client_count_.find(tqueue_id) != active_client_count_.end()) {
|
|
|
|
|
|
|
|
// return query->set_retry_after_error(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
auto id = clients_.create(ClientInfo{BotStatActor(stat_.actor_id(&stat_)), token, td::ActorOwn<Client>()});
|
|
|
|
auto id =
|
|
|
|
|
|
|
|
clients_.create(ClientInfo{BotStatActor(stat_.actor_id(&stat_)), token, tqueue_id, td::ActorOwn<Client>()});
|
|
|
|
auto *client_info = clients_.get(id);
|
|
|
|
auto *client_info = clients_.get(id);
|
|
|
|
client_info->client_ =
|
|
|
|
client_info->client_ = td::create_actor<Client>(PSLICE() << "Client/" << token, actor_shared(this, id),
|
|
|
|
td::create_actor<Client>(PSLICE() << "Client/" << token, actor_shared(this, id), query->token().str(),
|
|
|
|
query->token().str(), query->is_test_dc(), tqueue_id, parameters_,
|
|
|
|
query->is_test_dc(), get_tqueue_id(r_user_id.ok(), query->is_test_dc()), parameters_,
|
|
|
|
client_info->stat_.actor_id(&client_info->stat_));
|
|
|
|
client_info->stat_.actor_id(&client_info->stat_));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto method = query->method();
|
|
|
|
auto method = query->method();
|
|
|
|
if (method != "deletewebhook" && method != "setwebhook") {
|
|
|
|
if (method != "deletewebhook" && method != "setwebhook") {
|
|
|
|
@ -382,6 +386,21 @@ PromisedQueryPtr ClientManager::get_webhook_restore_query(td::Slice token, td::S
|
|
|
|
return PromisedQueryPtr(query.release(), PromiseDeleter(td::PromiseActor<td::unique_ptr<Query>>()));
|
|
|
|
return PromisedQueryPtr(query.release(), PromiseDeleter(td::PromiseActor<td::unique_ptr<Query>>()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ClientManager::raw_event(const td::Event::Raw &event) {
|
|
|
|
|
|
|
|
auto id = get_link_token();
|
|
|
|
|
|
|
|
auto *info = clients_.get(id);
|
|
|
|
|
|
|
|
CHECK(info != nullptr);
|
|
|
|
|
|
|
|
auto &value = active_client_count_[info->tqueue_id_];
|
|
|
|
|
|
|
|
if (event.ptr != nullptr) {
|
|
|
|
|
|
|
|
value++;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
CHECK(value > 0);
|
|
|
|
|
|
|
|
if (--value == 0) {
|
|
|
|
|
|
|
|
active_client_count_.erase(info->tqueue_id_);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ClientManager::hangup_shared() {
|
|
|
|
void ClientManager::hangup_shared() {
|
|
|
|
auto id = get_link_token();
|
|
|
|
auto id = get_link_token();
|
|
|
|
auto *info = clients_.get(id);
|
|
|
|
auto *info = clients_.get(id);
|
|
|
|
@ -391,6 +410,7 @@ void ClientManager::hangup_shared() {
|
|
|
|
clients_.erase(id);
|
|
|
|
clients_.erase(id);
|
|
|
|
|
|
|
|
|
|
|
|
if (close_flag_ && clients_.empty()) {
|
|
|
|
if (close_flag_ && clients_.empty()) {
|
|
|
|
|
|
|
|
CHECK(active_client_count_.empty());
|
|
|
|
close_db();
|
|
|
|
close_db();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|