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

Prioritise non proxy connections

parent 930bbe0e
No related branches found
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
......@@ -32,7 +32,7 @@ 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")) {
net_->bind("find_stream", [net = net_](const std::string &uri) -> optional<ftl::UUID> {
net_->bind("find_stream", [net = net_](const std::string &uri, bool proxy) -> optional<ftl::UUID> {
LOG(INFO) << "REQUEST FIND STREAM: " << uri;
ftl::URI u1(uri);
......@@ -242,7 +242,10 @@ bool Net::begin() {
//}
});
auto p = net_->findOne<ftl::UUID>("find_stream", uri_);
// First find non-proxy version, then check for proxy version if no match
auto p = net_->findOne<ftl::UUID>("find_stream", uri_, false);
if (!p) p = net_->findOne<ftl::UUID>("find_stream", uri_, true);
if (!p) {
LOG(INFO) << "Hosting stream: " << uri_;
// TODO: Register URI as available.
......
......@@ -380,7 +380,9 @@ app.ws('/', (ws, req) => {
}
});
p.bind("find_stream", (uri) => {
p.bind("find_stream", (uri, proxy) => {
if (!proxy) return null;
const parsedURI = stringSplitter(uri)
if (uri_to_peer.hasOwnProperty(parsedURI)) {
console.log("Stream found: ", uri, parsedURI);
......
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