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

16 handling connections requests #24

Merged
merged 8 commits into from
Feb 6, 2024
Merged

Conversation

Frlundsten
Copy link
Contributor


Handling connection request for the first time

We should validate the connections made according to MQTT protocol


Related Issue(s)

Closes #16

Proposed Changes

I suggest a separate class that can validate packages sent from a client to the server. The server can then respont to the client if connection is valid.

  • Change 1: A new class called PackageReader.
  • Change 2: Check connections in ClientHandler class before adding client to list.

Here are some example changes:

  • Clienthandler get private final PackageReader field.
  • We can read clients socket output and validate its package. If package is valid, the Connect message will be mapped with InetAdress of the clients socket. If a socket tries to send a second Connect package, the map inside PackageReader will trigger a statement that returns value false to Clienthandler, ending up closing the socket.

@Frlundsten Frlundsten linked an issue Feb 5, 2024 that may be closed by this pull request
Copy link
Contributor

@Win-ther Win-ther left a comment

Choose a reason for hiding this comment

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

isValidConnection method needs to return true. Other than that the code looks good.

Win-ther
Win-ther previously approved these changes Feb 5, 2024
@Emmelie83 Emmelie83 self-requested a review February 6, 2024 00:05
@Frlundsten Frlundsten self-assigned this Feb 6, 2024
@Emmelie83 Emmelie83 removed their request for review February 6, 2024 09:21
Copy link

@TrungMa1 TrungMa1 left a comment

Choose a reason for hiding this comment

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

Tests could be done for isConnectPackage method in PackageReader class.

src/main/java/org/fungover/thunder/PackageReader.java Outdated Show resolved Hide resolved
src/main/java/org/fungover/thunder/PackageReader.java Outdated Show resolved Hide resolved
@Frlundsten
Copy link
Contributor Author

Frlundsten commented Feb 6, 2024

Tests could be done for isConnectPackage method in PackageReader class.

Absolutely , I will make some tests👍

Copy link

@TrungMa1 TrungMa1 left a comment

Choose a reason for hiding this comment

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

Good job!

@kappsegla kappsegla added this pull request to the merge queue Feb 6, 2024
Merged via the queue into main with commit 4c20d5b Feb 6, 2024
1 check failed
@kappsegla kappsegla deleted the 16-handling-connections-requests branch February 6, 2024 15:30
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.

Handling connections requests
4 participants