bisschen aufgeräumt

This commit is contained in:
ahren 2023-12-13 13:53:07 +01:00
parent e617b11f86
commit de596fad8c
6 changed files with 65 additions and 109 deletions

View File

@ -18,9 +18,7 @@ public class Start
{
public Start()
{
//Transmitter transmitter = new Transmitter();
ChatView view = new ChatView();
//CommandController controller_commands = new CommandController(view, transmitter);
CommandController controller_commands = new CommandController(view);
controller_commands.registerEvents();
controller_commands.registerCommands();

View File

@ -8,9 +8,6 @@ package ChatProgramm.controller;
import ChatProgramm.controller.commands.CommandConnect;
import ChatProgramm.controller.commands.CommandInvoker;
import ChatProgramm.controller.commands.CommandSend;
import ChatProgramm.model.Client;
import ChatProgramm.model.Server;
import ChatProgramm.model.Transmitter;
import ChatProgramm.view.ChatView;
import java.awt.Component;
import java.awt.event.ActionEvent;
@ -23,15 +20,8 @@ import java.awt.event.ActionListener;
public class CommandController implements ActionListener{
private ChatView view;
//private Transmitter transmitter;
private CommandInvoker invoker;
// public CommandController(ChatView view, Transmitter transmitter){
// this.view = view;
// this.transmitter = transmitter;
// this.invoker = new CommandInvoker();
// }
public CommandController(ChatView view){
this.view = view;
this.invoker = new CommandInvoker();

View File

@ -10,7 +10,6 @@ import ChatProgramm.model.Server;
import ChatProgramm.util.OhmLogger;
import ChatProgramm.view.ChatView;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JDialog;
import javax.swing.JRadioButton;

View File

@ -13,6 +13,5 @@ public interface CommandInterface
{
public void execute();
public void undo();
// public void redo();
public boolean isUndoable();
}

View File

@ -12,24 +12,12 @@ package ChatProgramm.model;
public class Nachricht
{
private String nachricht;
//private int id;
public Nachricht(String nachricht)
{
this.nachricht = nachricht;
//this.id = id;
}
/**
* @return the id
*/
// public int getId() {
// return id;
// }
/**
* @return the nachricht
*/
@ -40,5 +28,4 @@ public class Nachricht
public void setNachricht(String nachricht) {
this.nachricht = nachricht;
}
}

View File

@ -13,7 +13,6 @@ import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -91,19 +90,6 @@ public abstract class Transmitter implements Runnable, Subscriber<String>, Trans
writer.flush();
lg.info("Nachricht gesendet");
textPublisher.submit(nachricht);
//
// String nachricht = in.readLine(); // ACHTUNG blockiert
// lg.info("Client: Serverbestätigung erhalten");
//
// lg.info("Client: fertig");
// in.close();
// out.close();
// s.close();
// in.close();
// out.close();
// s.close();
}
public Nachricht receive(){
Nachricht nachricht = new Nachricht("");
@ -118,22 +104,24 @@ public abstract class Transmitter implements Runnable, Subscriber<String>, Trans
} catch (IOException e) {
throw new RuntimeException(e);
}
return nachricht;
}
// public void disconnect (){
// in.close();
// out.close();
// s.close();
// }
@Override
public void run() {
while (true) {
lg.info("Warte auf Nachricht");
if(laufend) {
Nachricht eingehendeNachricht = receive();
if(!eingehendeNachricht.getNachricht().isEmpty()){
textPublisher.submit(eingehendeNachricht);
}
}
else{
break;
@ -167,15 +155,10 @@ public abstract class Transmitter implements Runnable, Subscriber<String>, Trans
synchronized (this){
laufend = true;
}
if (eService == null){
eService = Executors.newSingleThreadExecutor();
eService.execute(this);
}
lg.info("Starte Chat");
}
}