From dad15d52d21f29e9dc3a6d3bd17c9921d376c4bf Mon Sep 17 00:00:00 2001 From: Andrin Fassbind Date: Sat, 16 Apr 2022 19:40:51 +0200 Subject: [PATCH] javadoc --- .../client/ChatWindowController.java | 15 +++++------ .../client/ClientConnectionHandler.java | 26 +++++++++---------- .../server/ServerConnectionHandler.java | 14 ---------- 3 files changed, 20 insertions(+), 35 deletions(-) diff --git a/client/src/main/java/ch/zhaw/pm2/multichat/client/ChatWindowController.java b/client/src/main/java/ch/zhaw/pm2/multichat/client/ChatWindowController.java index 48ee896..c09d7ae 100644 --- a/client/src/main/java/ch/zhaw/pm2/multichat/client/ChatWindowController.java +++ b/client/src/main/java/ch/zhaw/pm2/multichat/client/ChatWindowController.java @@ -23,7 +23,6 @@ import static ch.zhaw.pm2.multichat.protocol.ConnectionHandler.State.*; * To Contact the Model Elements needed it also holds references to message and the Connectionhandler. */ public class ChatWindowController { - public Button sendButton; //TODO necessary to have a attribute when not used or delete? private ClientConnectionHandler connectionHandler; private ClientMessageList messages; private final WindowCloseHandler windowCloseHandler = new WindowCloseHandler(); @@ -44,6 +43,8 @@ public class ChatWindowController { private Button connectButton; @FXML private TextField filterValue; + @FXML + private Button sendButton; /** @@ -69,7 +70,7 @@ public class ChatWindowController { } /** - * Method which closes the Application via use of the disconnect Method. //TODO evtl Löschen? + * Method which closes the Application via use of the disconnect Method. */ private void applicationClose() { disconnect(); @@ -121,7 +122,7 @@ public class ChatWindowController { */ @FXML private void message() { - String messageString = messageField.getText().strip(); //TODO MVC ok? + String messageString = messageField.getText().strip(); try { if (connectionHandler == null) { addError("No connection handler"); @@ -190,7 +191,7 @@ public class ChatWindowController { public void setUserName(String userName) { Platform.runLater(new Runnable() { @Override - public void run() { //TODO MVC ok?? + public void run() { userNameField.setText(userName); } }); @@ -234,14 +235,13 @@ public class ChatWindowController { } /** - * Nested Class in charge of Closing the wind + * Nested Class in charge of Closing the window */ class WindowCloseHandler implements EventHandler { /** - * //TODO * - * @param event the event which occurred + * @param event the event which occurred when Windows is closed */ public void handle(WindowEvent event) { applicationClose(); @@ -251,7 +251,6 @@ public class ChatWindowController { /** * Starts several new Listener for Connection Handler changes by using several observable properties. */ - public void startConnectionHandlerListener() { connectionHandler.getStateProperty().addListener(new ChangeListener() { @Override diff --git a/client/src/main/java/ch/zhaw/pm2/multichat/client/ClientConnectionHandler.java b/client/src/main/java/ch/zhaw/pm2/multichat/client/ClientConnectionHandler.java index 0bae72f..769ff94 100644 --- a/client/src/main/java/ch/zhaw/pm2/multichat/client/ClientConnectionHandler.java +++ b/client/src/main/java/ch/zhaw/pm2/multichat/client/ClientConnectionHandler.java @@ -47,12 +47,12 @@ public class ClientConnectionHandler extends ConnectionHandler implements Runnab } /** - * //TODO complete javadoc + * Called to initialize the ClientConnectionHandler when trying to start a connection * - * @param serverAddress - * @param serverPort - * @param userName - * @throws IOException + * @param serverAddress to connect to + * @param serverPort to connect to + * @param userName to connect as + * @throws IOException if connection to Server not possible */ public void initialize(String serverAddress, int serverPort, String userName) throws IOException { state.set(NEW); @@ -155,7 +155,7 @@ public class ClientConnectionHandler extends ConnectionHandler implements Runnab } catch (IOException e) { System.err.println("Failed to close connection." + e.getMessage()); } - System.out.println("Closed Connection Handler to Server"); //TODO should be shown also when failed to close ? + System.out.println("Closed Connection Handler to Server"); } /** @@ -255,7 +255,7 @@ public class ClientConnectionHandler extends ConnectionHandler implements Runnab } /** - * //Connects TODO + * Send connect attempt to Server * * @throws ChatProtocolException Error that is thrown if the state is not set to NEW */ @@ -266,9 +266,9 @@ public class ClientConnectionHandler extends ConnectionHandler implements Runnab } /** - * //TODO + * Send Disconnect attempt to server * - * @throws ChatProtocolException + * @throws ChatProtocolException Error tha si thrown if state is invalid */ public void disconnect() throws ChatProtocolException { if (state.get() != NEW && state.get() != CONNECTED) @@ -278,11 +278,11 @@ public class ClientConnectionHandler extends ConnectionHandler implements Runnab } /** - * //TODO + * Sends message to Server * - * @param messageString - * @return - * @throws ChatProtocolException + * @param messageString The message the user wants to send + * @return true if message is valid else false + * @throws ChatProtocolException if illegal connection state */ public boolean message(String messageString) throws ChatProtocolException { if (state.get() != CONNECTED) throw new ChatProtocolException("Illegal state for message: " + state); diff --git a/server/src/main/java/ch/zhaw/pm2/multichat/server/ServerConnectionHandler.java b/server/src/main/java/ch/zhaw/pm2/multichat/server/ServerConnectionHandler.java index 25e7a49..d246c66 100644 --- a/server/src/main/java/ch/zhaw/pm2/multichat/server/ServerConnectionHandler.java +++ b/server/src/main/java/ch/zhaw/pm2/multichat/server/ServerConnectionHandler.java @@ -75,20 +75,6 @@ public class ServerConnectionHandler extends ConnectionHandler implements Runnab this.connectionRegistry = registry; } - /** //TODO needed method? - * @return the username of the connected client - */ - public String getUserName() { - return this.userName; - } - - /** //TODO needed method? - * @return state of the connection. Possible states are see {@link ch.zhaw.pm2.multichat.protocol.ConnectionHandler.State} - */ - public State getState() { - return state; - } - /** * These methods runs in a while-loop as long as the socket between server and client is available * and the connection State is not ERROR.