Skip to content
Snippets Groups Projects
Commit 1759fcdd authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Install default rpc handlers

parent e670e3b7
No related branches found
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
Pipeline #28599 canceled
......@@ -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");
......
......@@ -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));
});
......
......@@ -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);
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment