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

remove-disconnected-clients #36

Merged
merged 4 commits into from
Feb 7, 2024
Merged

remove-disconnected-clients #36

merged 4 commits into from
Feb 7, 2024

Conversation

Augry2
Copy link
Contributor

@Augry2 Augry2 commented Feb 6, 2024

Proposed Changes

Remove disconnected clients

Description

Added a method that removes disconnected clients from the clients list

while (iterator.hasNext()) {
Socket client = iterator.next();
if (client.isClosed()) {
System.out.println("Client disconnected: " + client.getInetAddress().getHostName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! I think your methods look good. Consider using logger.info(Log4j) instead of System.out.println. It provides better flexibility for handling log messages and is more advantageous in larger projects.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good suggestion, i will look into this!

Copy link
Contributor

@kappsegla kappsegla Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to introduce logging using a logging framework like Log4j I suggest that we create an issue for that. Because using a framework means we will have dependencies in runtime that must be included in our Dockerfile so changes must be made there also.

Unless we use the built in logging from java.util.logging.
Pros/Cons? https://www.loggly.com/ultimate-guide/java-logging-basics/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point

@Ebyrdeu Ebyrdeu mentioned this pull request Feb 6, 2024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't we missing detection of DISCONNECT messages from the client that will be sent to our server before closing the connection? This code handles removal of clients that are forcefully disconnected and the Socket is closed? But we must also handle graceful disconnects.

Might also be time to introduce some sort of Client object to store in the list since the Socket reference is only a part of the information we need to store for a client? We also might need to store clientId, a list of Topics that the client is subscribed to and other status information.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct this method only handles when a client is forcefully disconnected

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good, but doesnt solve disconnects should be fine since there is an #18 being worked on

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good, but doesnt solve disconnects should be fine since there is an #18 being worked on

Copy link
Contributor

@Emmelie83 Emmelie83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@kappsegla kappsegla added this pull request to the merge queue Feb 7, 2024
Merged via the queue into main with commit 2daa0a8 Feb 7, 2024
1 check passed
@kappsegla kappsegla deleted the remove-disconnected-clients branch February 7, 2024 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants