Make ts run better.
Change-Id: I5bdaa0e1bda5aaca6d29e4a0948fe6151e616af0
diff --git a/aos/network/web_proxy_main.cc b/aos/network/web_proxy_main.cc
index 479320a..7ea3ff4 100644
--- a/aos/network/web_proxy_main.cc
+++ b/aos/network/web_proxy_main.cc
@@ -15,17 +15,23 @@
std::vector<std::unique_ptr<aos::web_proxy::Subscriber>> *subscribers,
const aos::FlatbufferDetachedBuffer<aos::Configuration> &config) {
aos::ShmEventLoop event_loop(&config.message());
- const aos::Node *self = aos::configuration::GetMyNode(&config.message());
+ const bool is_multi_node =
+ aos::configuration::MultiNode(event_loop.configuration());
+ const aos::Node *self =
+ is_multi_node ? aos::configuration::GetMyNode(event_loop.configuration())
+ : nullptr;
+
+ LOG(INFO) << "My node is " << aos::FlatbufferToJson(self);
// TODO(alex): skip fetchers on the wrong node.
for (uint i = 0; i < config.message().channels()->size(); ++i) {
auto channel = config.message().channels()->Get(i);
- if (!aos::configuration::ChannelIsReadableOnNode(channel, self)) {
- subscribers->emplace_back(nullptr);
- } else {
+ if (aos::configuration::ChannelIsReadableOnNode(channel, self)) {
auto fetcher = event_loop.MakeRawFetcher(channel);
subscribers->emplace_back(
std::make_unique<aos::web_proxy::Subscriber>(std::move(fetcher), i));
+ } else {
+ subscribers->emplace_back(nullptr);
}
}
@@ -33,7 +39,9 @@
auto timer = event_loop.AddTimer([&]() {
for (auto &subscriber : *subscribers) {
- subscriber->RunIteration();
+ if (subscriber != nullptr) {
+ subscriber->RunIteration();
+ }
}
});
diff --git a/aos/network/www/proxy.ts b/aos/network/www/proxy.ts
index 80c71b2..13f4636 100644
--- a/aos/network/www/proxy.ts
+++ b/aos/network/www/proxy.ts
@@ -1,5 +1,6 @@
import {ConfigHandler} from './config_handler';
import {Configuration} from 'aos/configuration_generated';
+import * as WebProxy from 'aos/network/web_proxy_generated';
// There is one handler for each DataChannel, it maintains the state of
// multi-part messages and delegates to a callback when the message is fully
@@ -73,7 +74,7 @@
const fbBuffer = new flatbuffers.ByteBuffer(new Uint8Array(e.data));
// TODO(alex): handle config updates if/when required
if (!this.configHandler) {
- const config = aos.Configuration.getRootAsConfiguration(fbBuffer);
+ const config = Configuration.getRootAsConfiguration(fbBuffer);
this.config = config;
this.configHandler = new ConfigHandler(config, this.dataChannel);
this.configHandler.printConfig();