Fixed whitespaces ChatWindow.fxml other javadocs in other classes aswell deleted unneccessary declarations
This commit is contained in:
@@ -6,8 +6,7 @@ import java.io.IOException;
|
||||
import java.net.SocketException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
|
||||
/**
|
||||
* This Class represents a Server. The user can start the programm with the port number as a argument.
|
||||
@@ -84,13 +83,11 @@ public class Server {
|
||||
* The connection will be registered in the connection registry if successful.
|
||||
*/
|
||||
private void start() {
|
||||
ReentrantLock mutex = new ReentrantLock();
|
||||
Condition nameComplete = mutex.newCondition();
|
||||
System.out.println("Server started.");
|
||||
try {
|
||||
while (true) {
|
||||
NetworkHandler.NetworkConnection<String> connection = networkServer.waitForConnection();
|
||||
ServerConnectionHandler connectionHandler = new ServerConnectionHandler(connection, connections, mutex, nameComplete);
|
||||
ServerConnectionHandler connectionHandler = new ServerConnectionHandler(connection, connections);
|
||||
new Thread(connectionHandler).start();
|
||||
}
|
||||
} catch (SocketException e) {
|
||||
|
||||
@@ -14,13 +14,12 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Scanner;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
|
||||
/**
|
||||
* This class represents the connection between the server and a client and offers the serverside logic.
|
||||
* The ServerConnectionHandler receives data send from the client aswell as sends data to the client.
|
||||
* The ServerConnectionHandler receives data send from the client as well as sends data to the client.
|
||||
* <p>
|
||||
* The ServeConnectionHandler offers following functionality:
|
||||
* <p>
|
||||
@@ -48,10 +47,6 @@ public class ServerConnectionHandler extends ConnectionHandler implements Runnab
|
||||
private final int connectionId = connectionCounter.incrementAndGet();
|
||||
private final Map<String, ServerConnectionHandler> connectionRegistry;
|
||||
|
||||
private final ReentrantLock mutex;
|
||||
|
||||
private final Condition nameComplete;
|
||||
|
||||
private String userName = "Anonymous-" + connectionId;
|
||||
private State state = NEW;
|
||||
|
||||
@@ -68,21 +63,19 @@ public class ServerConnectionHandler extends ConnectionHandler implements Runnab
|
||||
*
|
||||
* @param connection representing the socket connection between server and client
|
||||
* @param registry map containing all active connections between server and clients
|
||||
* @param mutex to lock thread
|
||||
* @param nameComplete condition to call threads
|
||||
|
||||
|
||||
*/
|
||||
public ServerConnectionHandler(NetworkHandler.NetworkConnection<String> connection,
|
||||
Map<String, ServerConnectionHandler> registry, ReentrantLock mutex, Condition nameComplete) {
|
||||
Map<String, ServerConnectionHandler> registry) {
|
||||
super();
|
||||
setConnection(connection);
|
||||
Objects.requireNonNull(connection, "Connection must not be null");
|
||||
Objects.requireNonNull(registry, "Registry must not be null");
|
||||
this.connectionRegistry = registry;
|
||||
this.mutex = mutex;
|
||||
this.nameComplete = nameComplete;
|
||||
}
|
||||
|
||||
/**
|
||||
/** //TODO needed method?
|
||||
* @return the username of the connected client
|
||||
*/
|
||||
public String getUserName() {
|
||||
|
||||
Reference in New Issue
Block a user