Browse Source

Bisschen aufgeräumt und Logger aktualisiert

Jens
Js_Sman 1 year ago
parent
commit
a25f1617c8

+ 0
- 1
src/ChatProgramm/controller/commands/CommandSend.java View File

@@ -43,7 +43,6 @@ public class CommandSend implements CommandInterface
public void execute()
{
if(transmitterInterface != null && !eingabeFeld.getText().isEmpty()){
lg.info("Sende Nachricht");
transmitterInterface.send(new Nachricht(eingabeFeld.getText()));
eingabeFeld.setText("");
}

+ 2
- 1
src/ChatProgramm/model/Client.java View File

@@ -4,6 +4,7 @@
*/
package ChatProgramm.model;

import ChatProgramm.util.OhmLogger;
import ChatProgramm.view.ChatView;

import java.io.IOException;
@@ -17,7 +18,7 @@ import java.util.logging.*;
*/
public class Client extends Transmitter {

private static Logger lg = Logger.getLogger("netz");
private static Logger lg = OhmLogger.getLogger();


public Client(ChatView view) throws IOException {

+ 2
- 1
src/ChatProgramm/model/Server.java View File

@@ -5,6 +5,7 @@
package ChatProgramm.model;

import ChatProgramm.model.Transmitter;
import ChatProgramm.util.OhmLogger;
import ChatProgramm.view.ChatView;

import java.io.BufferedReader;
@@ -29,7 +30,7 @@ import java.util.logging.*;
*/
public class Server extends Transmitter {

private static Logger lg = Logger.getLogger("netz");
private static Logger lg = OhmLogger.getLogger();


@Override

+ 5
- 6
src/ChatProgramm/model/Transmitter.java View File

@@ -6,6 +6,7 @@ package ChatProgramm.model;

import ChatProgramm.controller.Nachricht;
import ChatProgramm.controller.ReceiveAdapter;
import ChatProgramm.util.OhmLogger;
import ChatProgramm.view.ChatView;

import java.io.BufferedReader;
@@ -15,7 +16,6 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -35,7 +35,7 @@ public abstract class Transmitter implements Runnable, Subscriber<Nachricht>, Tr
protected static final int PORT = 35000;
protected static final String IP = "127.0.0.1";

private static Logger lg = Logger.getLogger("netz");
private static Logger lg = OhmLogger.getLogger();

protected Socket socket;
protected BufferedReader reader;
@@ -104,11 +104,10 @@ public abstract class Transmitter implements Runnable, Subscriber<Nachricht>, Tr
writer.flush();

lg.info("Nachricht wird angezeigt");
lg.info(nachricht.getNachricht());
textPublisher.submit(nachricht);
}

public Nachricht recieve(){
public Nachricht receive(){
Nachricht nachricht = new Nachricht("");
try {
String txtNachricht = reader.readLine();
@@ -130,9 +129,9 @@ public abstract class Transmitter implements Runnable, Subscriber<Nachricht>, Tr
@Override
public void run() {
while (true) {
lg.info("running");
lg.info("Warte auf Nachricht");
if(laufend) {
Nachricht eingehendeNachricht = recieve();
Nachricht eingehendeNachricht = receive();

if(!eingehendeNachricht.getNachricht().isEmpty()){
textPublisher.submit(eingehendeNachricht);

+ 1
- 3
src/ChatProgramm/model/TransmitterInterface.java View File

@@ -2,9 +2,7 @@ package ChatProgramm.model;

import ChatProgramm.controller.Nachricht;

import java.util.concurrent.Flow;

public interface TransmitterInterface{
public void send(Nachricht nachricht);
public Nachricht recieve();
public Nachricht receive();
}

Loading…
Cancel
Save