JavaDoc überall eingefügt.
This commit is contained in:
parent
246abce07b
commit
3914fae45d
5 changed files with 135 additions and 115 deletions
|
@ -16,17 +16,14 @@
|
|||
*/
|
||||
package server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.PipedInputStream;
|
||||
import java.io.PipedOutputStream;
|
||||
import java.io.PipedReader;
|
||||
import java.io.PipedWriter;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.net.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import utils.Client;
|
||||
import utils.FifoPipe;
|
||||
|
||||
/**
|
||||
* Hauptklasse des Servers
|
||||
|
@ -37,45 +34,43 @@ import utils.FifoPipe;
|
|||
public class MainServer {
|
||||
|
||||
/**
|
||||
* Einstiegsklasse des Servers. Diese wartet auf Anfragen der Clients und erstellt dann die nötigen Resourcen (Streams und Threads).
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
boolean continueLoop = true;
|
||||
try (ServerSocket serverSocket = new ServerSocket(1236)) {
|
||||
ClientStore clientStore = new ClientStore();
|
||||
while (continueLoop) {
|
||||
System.out.println("Warte auf Clients");
|
||||
while (true) {
|
||||
Logger.getLogger(MainServer.class.getName()).log(Level.INFO, String.format("Main: Warte auf Clients"));
|
||||
Socket client = serverSocket.accept();
|
||||
System.out.println("client connected");
|
||||
|
||||
Logger.getLogger(MainServer.class.getName()).log(Level.INFO, String.format("Main: Client verbunden"));
|
||||
|
||||
PipedOutputStream pipedOutputStream = new PipedOutputStream();
|
||||
PipedInputStream pipedInputStream = new PipedInputStream(pipedOutputStream);
|
||||
|
||||
|
||||
ObjectOutputStream pipedObjectOutputStream = new ObjectOutputStream(pipedOutputStream);
|
||||
ObjectInputStream pipedObjectInputStream = new ObjectInputStream(pipedInputStream);
|
||||
|
||||
|
||||
ObjectInputStream in = new ObjectInputStream(client.getInputStream());
|
||||
ObjectOutputStream out = new ObjectOutputStream(client.getOutputStream());
|
||||
|
||||
System.out.println("Streams created");
|
||||
|
||||
|
||||
Logger.getLogger(MainServer.class.getName()).log(Level.INFO, String.format("Main: Streams erstellt"));
|
||||
|
||||
Thread threadRecive = new ClientReciveMessageThread(in, clientStore);
|
||||
Thread threadPush = new ClientPushMessageThread(out, pipedObjectInputStream, clientStore);
|
||||
|
||||
System.out.println("Threads created");
|
||||
|
||||
|
||||
Logger.getLogger(MainServer.class.getName()).log(Level.INFO, String.format("Main: Threads erstellt"));
|
||||
|
||||
threadPush.start();
|
||||
threadRecive.start();
|
||||
|
||||
Logger.getLogger(MainServer.class.getName()).log(Level.INFO, String.format("Main: Threads gestartet"));
|
||||
|
||||
System.out.println("Threads started");
|
||||
|
||||
Client client = new Client(pipedObjectOutputStream, threadPush, threadRecive);
|
||||
System.out.println(client.getPusher() + "/" + client.getReciver() + "/" + client.getOutputStream());
|
||||
clientStore.addClient(client);
|
||||
|
||||
clientStore.addClient(new Client(pipedObjectOutputStream, threadPush, threadRecive));
|
||||
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Fehler: " + ex);
|
||||
Logger.getLogger(MainServer.class.getName()).log(Level.SEVERE, String.format("Main: Fehler: %s", ex));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue