@@ -70,19 +70,35 @@ bool WebsocketEndpointManager::adapterPruned( size_t caller_id ){
7070 return m_inputAdapters[caller_id] == nullptr ;
7171};
7272
73+ bool WebsocketEndpointManager::publishesToEndpoint (const size_t caller_id, const std::string& endpoint_id){
74+ auto config_it = m_endpoint_configs.find (endpoint_id);
75+ if ( config_it == m_endpoint_configs.end () || config_it->second .shutting_down || config_it->second .attempting_reconnect )
76+ return false ;
77+
78+ return caller_id < m_endpoint_producers[endpoint_id].size () &&
79+ m_endpoint_producers[endpoint_id][caller_id];
80+ }
81+
7382void WebsocketEndpointManager::send (const std::string& value, const size_t & caller_id) {
7483 // Safety check for caller_id
7584 // Get all endpoints this producer is connected to
7685 const auto & endpoints = m_producer_endpoints[caller_id];
77-
86+ // std::cout << " WHAT THE FUCK!!!\n";
7887 // For each endpoint this producer is connected to
7988 for (const auto & endpoint_id : endpoints) {
8089 // Double check the endpoint exists and producer is still valid
81- if (auto it = m_endpoints.find (endpoint_id);
82- it != m_endpoints.end () &&
83- caller_id < m_endpoint_producers[endpoint_id].size () &&
84- m_endpoint_producers[endpoint_id][caller_id]) {
85- it->second .get ()->send (value);
90+ // if (auto it = m_endpoints.find(endpoint_id);
91+ // it != m_endpoints.end() &&
92+ // caller_id < m_endpoint_producers[endpoint_id].size() &&
93+ // m_endpoint_producers[endpoint_id][caller_id]) {
94+ // it->second.get()->send(value);
95+ // // boost::asio::post(m_ioc, [endpoint_id, value, ep = it->second.get()]() {
96+ // // ep->send(value);
97+ // // });
98+ if (publishesToEndpoint (caller_id, endpoint_id)) {
99+ auto it = m_endpoints.find (endpoint_id);
100+ if ( it != m_endpoints.end ())
101+ it->second .get ()->send (value);
86102 // boost::asio::post(m_ioc, [endpoint_id, value, ep = it->second.get()]() {
87103 // ep->send(value);
88104 // });
0 commit comments