|
|
@@ -38,6 +38,7 @@ public abstract class Transmitter implements Runnable, Subscriber<String>, Trans |
|
|
|
protected PrintWriter writer; |
|
|
|
|
|
|
|
private Nachricht nachricht; |
|
|
|
private String txtNachricht; |
|
|
|
private boolean laufend; |
|
|
|
private SubmissionPublisher<Nachricht> textPublisher; |
|
|
|
private ExecutorService eService; |
|
|
@@ -53,6 +54,7 @@ public abstract class Transmitter implements Runnable, Subscriber<String>, Trans |
|
|
|
textPublisher = new SubmissionPublisher<>(); |
|
|
|
this.view = view; |
|
|
|
addWertSubscription(receiveAdapter); |
|
|
|
nachricht = new Nachricht(""); |
|
|
|
} |
|
|
|
|
|
|
|
public void addWertSubscription(Subscriber<Nachricht> subscriber) |
|
|
@@ -84,20 +86,20 @@ public abstract class Transmitter implements Runnable, Subscriber<String>, Trans |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void send(Nachricht nachricht){ |
|
|
|
|
|
|
|
writer.println(nachricht.getNachricht()); |
|
|
|
public void send(String txtNachricht){ |
|
|
|
|
|
|
|
writer.println(txtNachricht); |
|
|
|
writer.flush(); |
|
|
|
lg.info("Nachricht gesendet"); |
|
|
|
nachricht.setNachricht("\nDu: " + txtNachricht); |
|
|
|
textPublisher.submit(nachricht); |
|
|
|
} |
|
|
|
public Nachricht receive(){ |
|
|
|
Nachricht nachricht = new Nachricht(""); |
|
|
|
try { |
|
|
|
String txtNachricht = reader.readLine(); |
|
|
|
txtNachricht = reader.readLine(); |
|
|
|
if(!txtNachricht.isEmpty()){ |
|
|
|
lg.info("Nachricht erhalten"); |
|
|
|
nachricht.setNachricht("Er / Sie: " + txtNachricht); |
|
|
|
nachricht.setNachricht("\nEr / Sie: " + txtNachricht); |
|
|
|
return nachricht; |
|
|
|
} |
|
|
|
|
|
|
@@ -118,9 +120,9 @@ public abstract class Transmitter implements Runnable, Subscriber<String>, Trans |
|
|
|
while (true) { |
|
|
|
lg.info("Warte auf Nachricht"); |
|
|
|
if(laufend) { |
|
|
|
Nachricht eingehendeNachricht = receive(); |
|
|
|
if(!eingehendeNachricht.getNachricht().isEmpty()){ |
|
|
|
textPublisher.submit(eingehendeNachricht); |
|
|
|
nachricht = receive(); |
|
|
|
if(!nachricht.getNachricht().isEmpty()){ |
|
|
|
textPublisher.submit(nachricht); |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |