diff --git a/components/common/cpp/src/configuration.cpp b/components/common/cpp/src/configuration.cpp index f6300e67c93f5505e6f1d91a1a11d0f92dfacf48..f756d1d571927d9c8eb9e070e8b39761b007b962 100644 --- a/components/common/cpp/src/configuration.cpp +++ b/components/common/cpp/src/configuration.cpp @@ -341,7 +341,7 @@ void ftl::config::registerConfigurable(ftl::Configurable *cfg) { LOG(ERROR) << "Attempting to create a duplicate object: " << *uri; } else { config_instance[*uri] = cfg; - LOG(INFO) << "Registering instance: " << *uri; + //LOG(INFO) << "Registering instance: " << *uri; lk.unlock(); auto tags = cfg->get<vector<string>>("tags"); diff --git a/components/control/cpp/src/master.cpp b/components/control/cpp/src/master.cpp index 159fc403bca1d26f76a9a94afb77d8daa11d5184..d6a2f1cac2b0a0508436a6f69a5bcbc76b23f5e0 100644 --- a/components/control/cpp/src/master.cpp +++ b/components/control/cpp/src/master.cpp @@ -36,6 +36,18 @@ Master::Master(Configurable *root, Universe *net) state_.paused = !state_.paused; }); + net->bind("list_streams", []() { + return std::list<std::string>(); + }); + + net->bind("find_stream", [](const std::string &uri, bool proxy) { + return std::optional<ftl::UUID>{}; + }); + + net->bind("add_stream", [](const std::string &uri) { + + }); + net->bind("update_cfg", [](const std::string &uri, const std::string &value) { ftl::config::update(uri, nlohmann::json::parse(value)); }); diff --git a/components/streams/src/feed.cpp b/components/streams/src/feed.cpp index 76cfc60e56d1488282469cd0a7642c740212d5f8..defe19720ee5cfb0204477123b7bb0c8c911f733 100644 --- a/components/streams/src/feed.cpp +++ b/components/streams/src/feed.cpp @@ -154,6 +154,7 @@ Feed::Feed(nlohmann::json &config, ftl::net::Universe*net) : }); }); + if (net_->isBound("add_stream")) net_->unbind("add_stream"); net_->bind("add_stream", [this](ftl::net::Peer &p, std::string uri){ //UNIQUE_LOCK(mtx_, lk); _updateNetSources(&p, uri); diff --git a/components/streams/src/netstream.cpp b/components/streams/src/netstream.cpp index dfd3cfb4b9819ba1f9345c164f06284804d5a406..00910ec93d9fdcbad248bae8387e375bbd4cfec4 100644 --- a/components/streams/src/netstream.cpp +++ b/components/streams/src/netstream.cpp @@ -28,10 +28,12 @@ int64_t Net::last_msg__ = 0; MUTEX Net::msg_mtx__; static std::list<std::string> net_streams; +static std::atomic_flag has_bindings = ATOMIC_FLAG_INIT; static SHARED_MUTEX stream_mutex; Net::Net(nlohmann::json &config, ftl::net::Universe *net) : Stream(config), active_(false), net_(net), clock_adjust_(0), last_ping_(0) { - if (!net_->isBound("find_stream")) { + if (!has_bindings.test_and_set()) { + if (net_->isBound("find_stream")) net_->unbind("find_stream"); net_->bind("find_stream", [net = net_](const std::string &uri, bool proxy) -> optional<ftl::UUID> { LOG(INFO) << "REQUEST FIND STREAM: " << uri; @@ -48,9 +50,8 @@ Net::Net(nlohmann::json &config, ftl::net::Universe *net) : Stream(config), acti } return {}; }); - } - if (!net_->isBound("list_streams")) { + if (net_->isBound("list_streams")) net_->unbind("list_streams"); net_->bind("list_streams", [this]() { LOG(INFO) << "REQUEST LIST STREAMS"; SHARED_LOCK(stream_mutex, lk);