Crequency / KitX

An all-purpose toolbox app that connect everything.
https://kitx.apps.crequency.com
GNU Affero General Public License v3.0
1.17k stars 49 forks source link

[Dashboard] Refactoring requests related to web services #246

Closed Cronyet closed 1 year ago

Cronyet commented 1 year ago

🪦 Is your feature request related to a problem? Please describe.

Talk about KitX Dashboard. Currently, the code related to network services exists in the Servers directory. There are only two files:

Among them, DevicesServer.cs also contains the code of two parts, the device self-discovery network and the master-slave device communication network. All these codes jumbled together, as a result, there is no way to expand new functions easily at the same time. The state control of network services can only be distinguished by PluginsServer.cs and DevicesServer.cs. Restarting the device service must restart the device self-discovery network and the master-slave device communication network at the same time, instead of simply restarting one of them.

So, I opened this issue. I am going to have a discussion with you about refactoring the code related to network services

🪧 Describe the solution you'd like

The following is my refactoring idea:

We need a new library project, for example: KitX.Web.Core, placed in the KitX Dashboard Helper repository. Migrate all network related code to this project. Use more closure semantics to refactor network-related logic to prevent code in KitX.Web.Core from accessing KitX Dashboard. We need a network server interface design, for example: IKitXNetworkServer and it is required that the class that implements this interface must implement methods such as Start(), Stop(), etc. for better state control. In addition, we need to separate the device self-discovery network from the master-slave device communication network, so that one of the networks can be controlled independently

🧾 Describe alternatives you've considered

It's going to be a lot of work, but it's still worth it.

📎 Additional context

No response

Dynesshely commented 1 year ago

You're right, this is actually a problem needs to be solve.

Dynesshely commented 1 year ago

Tracked by #223 .

Cronyet commented 1 year ago

Considering that some surrounding facilities are inconvenient to migrate, I suggest rebuilding on the basis of the original project first, rather than creating a new project, just like what you are doing now.

Cronyet commented 1 year ago

Crequency/KitX-Dashboard#19 has been merged, we can close this issue while changes in KitX/dev=main merged into KitX/main