@@ -70,19 +70,35 @@ bool WebsocketEndpointManager::adapterPruned( size_t caller_id ){
70
70
return m_inputAdapters[caller_id] == nullptr ;
71
71
};
72
72
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
+
73
82
void WebsocketEndpointManager::send (const std::string& value, const size_t & caller_id) {
74
83
// Safety check for caller_id
75
84
// Get all endpoints this producer is connected to
76
85
const auto & endpoints = m_producer_endpoints[caller_id];
77
-
86
+ // std::cout << " WHAT THE FUCK!!!\n";
78
87
// For each endpoint this producer is connected to
79
88
for (const auto & endpoint_id : endpoints) {
80
89
// 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);
86
102
// boost::asio::post(m_ioc, [endpoint_id, value, ep = it->second.get()]() {
87
103
// ep->send(value);
88
104
// });
0 commit comments