Compare commits

..

No commits in common. "a4a45ed5f2df00096c31b1dcf68f7f1e55bfb12c" and "f05b0f00145b0b76b8c20edadf838eef5260b740" have entirely different histories.

5 changed files with 17 additions and 54 deletions

View File

@ -26,7 +26,7 @@ public class Start
GrafikView zeichenflaeche = view.getGvZeichenflaeche();
zeichenflaeche.setModel(model);
CommandController controller_commands = new CommandController(view, model);
CommandController controller_commands = new CommandController(view);
controller_commands.registerEvents();
controller_commands.registerCommands();

View File

@ -8,7 +8,6 @@ package ChatProgramm.controller;
import ChatProgramm.controller.commands.CommandConnect;
import ChatProgramm.controller.commands.CommandInvoker;
import ChatProgramm.controller.commands.CommandSend;
import ChatProgramm.model.GrafikModel;
import ChatProgramm.view.ChatView;
import java.awt.Component;
import java.awt.event.ActionEvent;
@ -21,12 +20,10 @@ import java.awt.event.ActionListener;
public class CommandController implements ActionListener{
private ChatView view;
private GrafikModel model;
private CommandInvoker invoker;
public CommandController(ChatView view, GrafikModel model){
public CommandController(ChatView view){
this.view = view;
this.model = model;
this.invoker = new CommandInvoker();
}
@ -37,7 +34,7 @@ public class CommandController implements ActionListener{
}
public void registerCommands(){
CommandSend commandSend = new CommandSend(view.getGvZeichenflaeche(), model);
CommandSend commandSend = new CommandSend(view.getGvZeichenflaeche());
invoker.addCommand(view.getBtnConnect(), new CommandConnect(view, commandSend));
//invoker.addCommand(view.getTfNachricht(), commandSend);
}

View File

@ -27,7 +27,7 @@ public class GrafikController extends MouseAdapter implements MouseMotionListene
{
this.view = view;
this.model = model;
commandSend = new CommandSend(view, model);
commandSend = new CommandSend(view);
}
public void registerEvents()

View File

@ -6,8 +6,6 @@
package ChatProgramm.controller.commands;
import ChatProgramm.model.Client;
import ChatProgramm.model.Figur;
import ChatProgramm.model.GrafikModel;
import ChatProgramm.model.Server;
import ChatProgramm.model.TransmitterInterface;
import ChatProgramm.util.OhmLogger;
@ -27,7 +25,6 @@ public class CommandSend implements CommandInterface
private JTextField eingabeFeld;
private String nachricht;
private GrafikView view;
private GrafikModel model;
public TransmitterInterface transmitterInterface;
public Server server;
public Client client;
@ -35,10 +32,9 @@ public class CommandSend implements CommandInterface
public CommandSend(GrafikView view, GrafikModel model)
public CommandSend(GrafikView view)
{
this.view = view;
this.model = model;
//ToDo: Hier muss auch der gFrame referenziert werden
//this.eingabeFeld = view.getTfNachricht();
transmitterInterface = null;
@ -48,13 +44,6 @@ public class CommandSend implements CommandInterface
public void execute()
{
lg.info("wir sind drin");
Figur aktuelleFigur = model.getFiguren().getLast();
if(transmitterInterface != null){
transmitterInterface.send(aktuelleFigur);
}
else{
lg.info("Der Transmitter ist immernoch null");
}
//ToDo in dieser methode muss die Figur serialisiert werden und zum
//übermitteln bereitgestellt werden
@ -75,15 +64,4 @@ public class CommandSend implements CommandInterface
public void undo()
{
}
void setTransmitter(TransmitterInterface transmitter) {
lg.info("Transmitter wird gesetzt");
if(transmitter != null){
this.transmitterInterface = transmitter;
}
else{
lg.info("der transmitter kommt hier als null an");
}
}
}

View File

@ -30,7 +30,7 @@ import java.util.logging.Logger;
*
* @author ahren
*/
public abstract class Transmitter implements Runnable, Subscriber<Figur>, TransmitterInterface {
public abstract class Transmitter implements Runnable, Subscriber<String>, TransmitterInterface {
static final int timeout = 60000;
private static final int PORT = 35000;
@ -74,13 +74,16 @@ public abstract class Transmitter implements Runnable, Subscriber<Figur>, Transm
InputStream is = socket.getInputStream();
OutputStream os = socket.getOutputStream();
// Bruh im ernst mann muss zuerst den writer und dann den reader initialisieren
// andersrum ist das blockierend weil die Streams von hinten nach vorne
// gelesen werden
writer = new ObjectOutputStream(os);
writer.flush();
reader = new ObjectInputStream(is);
lg.info("1");
BufferedOutputStream bos = new BufferedOutputStream(os);
BufferedInputStream bis = new BufferedInputStream(is);
lg.info("2");
// InputStreamReader isr = new InputStreamReader(is, "UTF-8");
// OutputStreamWriter osr = new OutputStreamWriter(os, "UTF-8");
reader = new ObjectInputStream(bis);
writer = new ObjectOutputStream(bos);
lg.info("Reader / Writer Initialisierung abgeschlossen");
startempfangen();
lg.info("Warte auf Nachricht");
@ -112,21 +115,6 @@ public abstract class Transmitter implements Runnable, Subscriber<Figur>, Transm
figurPublisher.submit(figur);
}
public Figur receive(){
Object receivedObject;
try {
receivedObject = reader.readObject();
if (receivedObject instanceof Figur) {
Figur receivedFigur = (Figur) receivedObject;
// Verarbeiten Sie die empfangene Figur
}
} catch (IOException ex) {
Logger.getLogger(Transmitter.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(Transmitter.class.getName()).log(Level.SEVERE, null, ex);
}
try {
figur = (Figur) reader.readObject();
if(!txtNachricht.isEmpty()){
@ -174,7 +162,7 @@ public abstract class Transmitter implements Runnable, Subscriber<Figur>, Transm
}
@Override
public void onNext(Figur item) {
public void onNext(String item) {
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}