diff --git a/applications/vision/src/streamer.cpp b/applications/vision/src/streamer.cpp index b9a3f78bb905383b94f002ccb431a863e897346d..0a4d0853583e7ef74d1f2985f56131c64598d9ec 100644 --- a/applications/vision/src/streamer.cpp +++ b/applications/vision/src/streamer.cpp @@ -54,7 +54,11 @@ void Streamer::send(const Mat &rgb, const Mat &depth) { cv::imencode(".png", d2, d_buf); LOG(INFO) << "Depth Size = " << ((float)d_buf.size() / (1024.0f*1024.0f)); - - net_.publish(uri_, rgb_buf, d_buf); + + try { + net_.publish(uri_, rgb_buf, d_buf); + } catch (...) { + LOG(ERROR) << "Exception on net publish to " << uri_; + } } diff --git a/components/net/cpp/include/ftl/net/universe.hpp b/components/net/cpp/include/ftl/net/universe.hpp index ccb6e12156fd02a7aece1ed4c84d44edf12f7719..8737286712e02979410aaef1462cb87cb29bec9d 100644 --- a/components/net/cpp/include/ftl/net/universe.hpp +++ b/components/net/cpp/include/ftl/net/universe.hpp @@ -138,6 +138,7 @@ class Universe : public ftl::Configurable { void _installBindings(); void _installBindings(Peer *); bool _subscribe(const std::string &res); + void _remove(Peer *); static void __start(Universe *u); diff --git a/components/net/cpp/src/universe.cpp b/components/net/cpp/src/universe.cpp index 130d7ec416f2022428435c901afcf78d6b85d426..721f72a1f0b196d2acd30fd147c34b515bbd60bc 100644 --- a/components/net/cpp/src/universe.cpp +++ b/components/net/cpp/src/universe.cpp @@ -150,6 +150,13 @@ void Universe::_installBindings() { }); } +// Note: should be called inside a net lock +void Universe::_remove(Peer *p) { + auto ix = peer_ids_.find(p->id()); + if (ix != peer_ids_.end()) peer_ids_.erase(ix); + delete p; +} + Peer *Universe::getPeer(const UUID &id) const { auto ix = peer_ids_.find(id); if (ix == peer_ids_.end()) return nullptr; @@ -295,8 +302,8 @@ void Universe::_run() { for (auto i=peers_.begin(); i!=peers_.end(); i++) { if ((*i) == s) { LOG(INFO) << "REMOVING SOCKET"; + _remove(*i); peers_.erase(i); break; - // TODO Remove subscribers } } }