Further improved Java Docs 10 missing todos.
This commit is contained in:
@@ -25,6 +25,19 @@ public class Server {
|
||||
// Connection registry
|
||||
private final Map<String, ServerConnectionHandler> connections = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The Constructor to create a new instance.
|
||||
*
|
||||
* @param serverPort to listen for incoming connections.
|
||||
* @throws IOException thrown if an I/O error occurs when opening the socket.
|
||||
*/
|
||||
public Server(int serverPort) throws IOException {
|
||||
// Open server connection
|
||||
System.out.println("Create server connection");
|
||||
networkServer = NetworkHandler.createServer(serverPort);
|
||||
System.out.println("Listening on " + networkServer.getHostAddress() + ":" + networkServer.getHostPort());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
@@ -66,19 +79,6 @@ public class Server {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Constructor to create a new instance.
|
||||
*
|
||||
* @param serverPort to listen for incoming connections.
|
||||
* @throws IOException thrown if an I/O error occurs when opening the socket.
|
||||
*/
|
||||
public Server(int serverPort) throws IOException {
|
||||
// Open server connection
|
||||
System.out.println("Create server connection");
|
||||
networkServer = NetworkHandler.createServer(serverPort);
|
||||
System.out.println("Listening on " + networkServer.getHostAddress() + ":" + networkServer.getHostPort());
|
||||
}
|
||||
|
||||
/**
|
||||
* With this methode the instance waits for incoming connections. If a client tries to connect to the server.
|
||||
* The connection will be registered in the connection registry if successful.
|
||||
|
||||
@@ -33,8 +33,8 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
* 1. Removing the connection from the {@link ServerConnectionHandler#connectionRegistry}
|
||||
* 2. Terminates the socket by calling {@link NetworkHandler.NetworkConnection#close()}
|
||||
* <p>
|
||||
* Processes Messages send from a client by:
|
||||
* 1. Evaluating the reciever by differentiating between broadcast or unicast.
|
||||
* Process Messages send from a client by:
|
||||
* 1. Evaluating the receiver by differentiating between broadcast or unicast.
|
||||
* 2. Sending the message accordingly.
|
||||
* <p>
|
||||
* To use this class, start a new instance and start it in a thread.
|
||||
@@ -89,7 +89,7 @@ public class ServerConnectionHandler extends ConnectionHandler implements Runnab
|
||||
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() {
|
||||
@@ -97,7 +97,7 @@ public class ServerConnectionHandler extends ConnectionHandler implements Runnab
|
||||
}
|
||||
|
||||
/**
|
||||
* This methods runs in a while-loop as long as the socket between server and client is available
|
||||
* 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.
|
||||
*/
|
||||
private void startReceiving() {
|
||||
|
||||
Reference in New Issue
Block a user