Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactoring]: Separate ServerConnection and ClientConnection from each other #4076

Closed
kwvanderlinde opened this issue May 19, 2023 · 1 comment
Assignees

Comments

@kwvanderlinde
Copy link
Collaborator

Describe the problem

When I have to look through the client-server code, I always get lost because the responsibilities and relationships of each type are not clear, and they have functionality that is foreign to their purpose. In particular, ServerConnection and ClientConnection are entangled with each other, both in interface and implementation, suggesting commonalities that do not really exist. The names and packages are also confusing: ClientConnection is used equally for the client-side and server-side of a connection; and ServerConnection is in no way a connection, though it does manage connections and forward messages to/from connections.

The improvement you'd like to see

The Connection interface would be removed, with its methods being moved into ServerConnection and ClientConnection according to their responsibilities. The broad strokes of responsibilities are:

  • ClientConnection is responsible for maintaining a connection, sending and receiving messages via that connection, and notifying about connection activity. It does this both client-side and server-side.
  • ServerConnection only has server-side responsibilities: managing connections to clients (via ClientConnection), sending messages to specific clients, and broadcasting messages to all connected clients.

Correspondingly, AbstractConnection would be removed, with its implementation being split between AbstractServerConnection and AbstractClientConnection.

Finally, with the types detangled, the names would also be changed to match their roles, e.g.:

  • ServerConnection -> Server
  • ClientConnection -> Connection

Expected Benefits

It will be easier to read and maintain the client-server code. Server complexities will no longer be foisted on connections and vice versa, allowing the two to evolve independently.

Additional Context

No response

@kwvanderlinde
Copy link
Collaborator Author

Closing this off as it's been in the wild for some time with no issues reported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

1 participant