55#include < csp/adapters/websocket/WebsocketEndpointManager.h>
66#include < csp/adapters/websocket/WebsocketClientTypes.h>
77#include < csp/adapters/websocket/ClientInputAdapter.h>
8- #include < csp/adapters/websocket/ClientOutputAdapter.h>
98#include < csp/adapters/websocket/ClientHeaderUpdateAdapter.h>
10- #include < csp/adapters/websocket/ClientConnectionRequestAdapter.h>
119#include < csp/core/Enum.h>
1210#include < csp/core/Hash.h>
1311#include < csp/engine/AdapterManager.h>
@@ -26,50 +24,8 @@ namespace csp::adapters::websocket {
2624
2725using namespace csp ;
2826
29- class ClientConnectionRequestAdapter ;
30- class ClientOutputAdapter ;
3127class WebsocketEndpointManager ;
3228
33-
34- // struct WebsocketClientStatusTypeTraits
35- // {
36- // enum _enum : unsigned char
37- // {
38- // ACTIVE = 0,
39- // GENERIC_ERROR = 1,
40- // CONNECTION_FAILED = 2,
41- // CLOSED = 3,
42- // MESSAGE_SEND_FAIL = 4,
43-
44- // NUM_TYPES
45- // };
46-
47- // protected:
48- // _enum m_value;
49- // };
50-
51- // struct ConnectPayloads {
52- // std::vector<std::string> consumer_payloads;
53- // std::vector<std::string> producer_payloads;
54- // };
55-
56- // struct EndpointConfig {
57- // std::chrono::milliseconds reconnect_interval;
58- // std::unique_ptr<boost::asio::steady_timer> reconnect_timer;
59- // bool attempting_reconnect{false};
60- // bool shutting_down{false}; // Track intentional shutdown
61-
62- // // Keep the payload storage
63- // std::vector<std::string> consumer_payloads;
64- // std::vector<std::string> producer_payloads;
65-
66- // EndpointConfig(boost::asio::io_context& ioc)
67- // : reconnect_timer(std::make_unique<boost::asio::steady_timer>(ioc))
68- // {}
69- // };
70-
71- // using ClientStatusType = Enum<WebsocketClientStatusTypeTraits>;
72-
7329class ClientAdapterManager final : public AdapterManager
7430{
7531
@@ -96,57 +52,8 @@ class ClientAdapterManager final : public AdapterManager
9652 DateTime processNextSimTimeSlice ( DateTime time ) override ;
9753
9854private:
99- inline size_t validateCallerId (int64_t caller_id) const {
100- if (caller_id < 0 ) {
101- CSP_THROW (ValueError, " caller_id cannot be negative: " << caller_id);
102- }
103- return static_cast <size_t >(caller_id);
104- }
105-
106- // need some client info
107- // This is a tuple of
108- // (number of send calls to uri, set of caller id's subscribed to uri )
109- // We use this information to keep track of how to route messages to/from
110- // uri's, and when a uri connection can be closed.
111- // using UriInfo = std::tuple<int32_t, std::unordered_set<uint64_t>>; //TODO remove
112- // using OptWorkGuard = std::optional<boost::asio::executor_work_guard<boost::asio::io_context::executor_type>>;
11355 Dictionary m_properties;
11456 std::unique_ptr<WebsocketEndpointManager> m_endpointManager;
115- // net::io_context m_ioc;
116- // [[maybe_unused]] bool m_active;
117- // [[maybe_unused]] bool m_shouldRun;
118- // std::unique_ptr<WebsocketEndpoint> m_endpoint; // TODO remove
119- // [[maybe_unused]] ClientInputAdapter* m_inputAdapter;
120- // [[maybe_unused]] ClientOutputAdapter* m_outputAdapter;
121- // ClientHeaderUpdateOutputAdapter* m_updateAdapter;
122- // std::unique_ptr<std::thread> m_thread;
123- // // For each subscribe call, which uri's it is subscribed to
124- // std::vector<std::unordered_set<std::string>> m_subscribeFromUri;
125- // // For each send call, which uri's it will send out to
126- // std::vector<std::unordered_set<std::string>> m_sendToUri;
127-
128- // // uri -> (send_calls, set of caller id's for the subscribtions)
129- // // If send_calls is 0 (no adapter is sending out to that uri)
130- // // AND the subscriptions set is empty, we can then shutdown the encpoint.
131- // std::unordered_map<std::string, UriInfo> m_uriInfo; //TODO: remove
132- // //unclear if this is needed to be on the object
133- // std::vector<ClientConnectionRequestAdapter*> m_connectionRequestAdapters;
134-
135- // // Bidirectional mapping using vectors since caller_ids are sequential
136- // // Maybe not efficient? Should be good for small number of edges though
137- // std::unordered_map<std::string, std::vector<bool>> m_endpoint_consumers; // endpoint_id -> vector[caller_id] for consuemrs
138- // std::unordered_map<std::string, std::vector<bool>> m_endpoint_producers; // endpoint_id -> vector[caller_id] for producers
139-
140- // // Quick lookup for caller's endpoints
141- // std::vector< std::unordered_set<std::string> > m_consumer_endpoints; // caller_id -> set of endpoints they consume from
142- // std::vector< std::unordered_set<std::string> > m_producer_endpoints; // caller_id -> set of endpoints they produce to
143- // OptWorkGuard m_work_guard;
144- // std::unordered_map<std::string, std::unique_ptr<WebsocketEndpoint>> m_endpoints;
145- // std::unordered_map<std::string, ConnectPayloads> m_connect_payloads;
146- // std::unordered_map<std::string, EndpointConfig> m_endpoint_configs;
147- // std::vector<ClientInputAdapter*> m_inputAdapters;
148- // std::vector<ClientOutputAdapter*> m_outputAdapters;
149- // bool m_dynamic;
15057};
15158
15259}
0 commit comments