I have a nodejs project where I try to build a bluetooth mesh like network, each node consists roughly of 4 parts the frontend part, the message broker, a bluetooth client and a bluetooth server.
The message broker creates the bluetooth server, client and all the dependencies and runs in its own node process, also the bluetooth server and client run in there own nodejs process (The server and client write large payloads directly to the disc and do some converting and compression/decompression in there threads).
This message broker has to handle messages from the frontend process (requests to do something from the user) and the bluetooth client (central) or the bluetooth server (peripheral) (requests from another node). Messages from the server and client will be delegated to specific message handlers frontend messages are handled by the broker himself.
These are my message broker related classes:
Where is the problem:
MetaDataManager (just an object to share necessary data between the broker, client and server, but it got very ugly by now there are multiple arrays to keep track of pending actions and past requests),
BluetoothStateController (keeps track of the blutooth adapter state so that the broker, client or server can check whether bluetooth is active and if so whether its scanning/advertising/connected)
BluetoothClientMessageHandler (the message boker passes all messages from the bluetooth client to this class, depending on the state, meta data and the received message a action is performed e.g. connect -> read data -> write data. All of this is async so the response for the connect, read and wirte action arrives all in the entry method of the handler from which it is delegated to another method)
BluetoothServerMessageHandler (Similar to the client)
What is the problem: The handlers are each around 300 lines of code with lots of conditionals (if else and switch case)(the messages are JSON objects from the other node processes) and so far I have failed to split them into smaller classes because they are too tightly coupled. Also I know that the word “handler” means that these classes are probably to broad and do not conform to the single responsibility principle. The open close principle is probably also violated because of the switch case statements within the message handlers.
I tried to split them into smaller classes but realized that I would need even more objects to share data between them thus the methods within the message handlers are also too tightly coupled.
Does someone see a way to decouple these classes ?
✓ Extra quality
ExtraProxies brings the best proxy quality for you with our private and reliable proxies
✓ Extra anonymity
Top level of anonymity and 100% safe proxies – this is what you get with every proxy package
✓ Extra speed
1,ooo mb/s proxy servers speed – we are way better than others – just enjoy our proxies!
USA proxy location
We offer premium quality USA private proxies – the most essential proxies you can ever want from USA
Our proxies have TOP level of anonymity + Elite quality, so you are always safe and secure with your proxies
Use your proxies as much as you want – we have no limits for data transfer and bandwidth, unlimited usage!
Superb fast proxy servers with 1,000 mb/s speed – sit back and enjoy your lightning fast private proxies!
99,9% servers uptime
Alive and working proxies all the time – we are taking care of our servers so you can use them without any problems
No usage restrictions
You have freedom to use your proxies with every software, browser or website you want without restrictions
Perfect for SEO
We are 100% friendly with all SEO tasks as well as internet marketing – feel the power with our proxies
Buy more proxies and get better price – we offer various proxy packages with great deals and discounts
We are working 24/7 to bring the best proxy experience for you – we are glad to help and assist you!