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

public void execute() public void execute()
{ {
if(transmitterInterface != null && !eingabeFeld.getText().isEmpty()){ if(transmitterInterface != null && !eingabeFeld.getText().isEmpty()){
lg.info("Sende Nachricht");
transmitterInterface.send(new Nachricht(eingabeFeld.getText())); transmitterInterface.send(new Nachricht(eingabeFeld.getText()));
eingabeFeld.setText(""); eingabeFeld.setText("");
} }

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

*/ */
package ChatProgramm.model; package ChatProgramm.model;


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


import java.io.IOException; import java.io.IOException;
*/ */
public class Client extends Transmitter { public class Client extends Transmitter {


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




public Client(ChatView view) throws IOException { public Client(ChatView view) throws IOException {

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

package ChatProgramm.model; package ChatProgramm.model;


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


import java.io.BufferedReader; import java.io.BufferedReader;
*/ */
public class Server extends Transmitter { public class Server extends Transmitter {


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




@Override @Override

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



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


import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.Socket; import java.net.Socket;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
protected static final int PORT = 35000; protected static final int PORT = 35000;
protected static final String IP = "127.0.0.1"; 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 Socket socket;
protected BufferedReader reader; protected BufferedReader reader;
writer.flush(); writer.flush();


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


public Nachricht recieve(){
public Nachricht receive(){
Nachricht nachricht = new Nachricht(""); Nachricht nachricht = new Nachricht("");
try { try {
String txtNachricht = reader.readLine(); String txtNachricht = reader.readLine();
@Override @Override
public void run() { public void run() {
while (true) { while (true) {
lg.info("running");
lg.info("Warte auf Nachricht");
if(laufend) { if(laufend) {
Nachricht eingehendeNachricht = recieve();
Nachricht eingehendeNachricht = receive();


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

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



import ChatProgramm.controller.Nachricht; import ChatProgramm.controller.Nachricht;


import java.util.concurrent.Flow;

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

Loading…
Cancel
Save