void connection_mgr::on_connected() { connected_sig(); auto self = shared_from_this(); m_connection->send_command("list_remotes", "" , [self] ( const bs::error_code &ec , const std::string& status , std::string& data ) { bs::error_code _ec = ec; if (!_ec && status != "k") _ec = make_iks_error_code(data); if (!_ec) { std::vector<remote_entry> remotes; if (self->parse_remotes(data, remotes)) for (auto& e : remotes) self->connect_location(e.first, e.second); else _ec = make_error_code(iks_client_error::invalid_server_response); } if (_ec) self->on_error(_ec); return IksCmdStatus::cmd_done; }); }
// the constructor is always called from python's thread only mastermind_t(const std::string &remotes, int update_period, std::string cache_path , int warning_time, int expire_time, std::string worker_name , int enqueue_timeout, int reconnect_timeout, bp::object ns_filter_, bool auto_start) { gil_guard_t gil_guard; auto native_remotes = parse_remotes(remotes); auto logger = std::make_shared<logger_t>(gil_guard); set_ns_filter(std::move(ns_filter_)); gil_guard.release(); py_allow_threads_scoped gil_release; impl = std::make_shared<mm::mastermind_t>( native_remotes, logger, update_period, std::move(cache_path) , warning_time, expire_time, std::move(worker_name) , enqueue_timeout, reconnect_timeout, false); impl->set_user_settings_factory([this] (const std::string &name , const kora::config_t &config) { return user_settings_factory(name, config); }); if (auto_start) { start_impl(gil_release); } }