Browse Source

Transmitter als Abstrakte Klasse

Jens
Jens Schuhmann 1 year ago
parent
commit
320c6041b7
1 changed files with 62 additions and 2 deletions
  1. 62
    2
      src/ChatProgramm/model/Transmitter.java

+ 62
- 2
src/ChatProgramm/model/Transmitter.java View File

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


import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
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.Flow; import java.util.concurrent.Flow;
import java.util.concurrent.Flow.Subscriber; import java.util.concurrent.Flow.Subscriber;
import java.util.logging.Level;
import java.util.logging.Logger;


/** /**
* *
* @author ahren * @author ahren
*/ */
public abstract class Transmitter implements Runnable{
static final int timeout = 10000;
public abstract class Transmitter implements Runnable, Subscriber<String> {

static final int timeout = 60000;
private static final int PORT = 35000;

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

private Socket socket;
private BufferedReader reader;
private PrintWriter writer;


public Transmitter() { public Transmitter() {




public abstract void connect() throws IOException; public abstract void connect() throws IOException;


public void initIO() {
try {
lg.info("Initialisiere reader und writer");
InputStream is = socket.getInputStream();
OutputStream os = socket.getOutputStream();

InputStreamReader isr = new InputStreamReader(is, "UTF-8");
OutputStreamWriter osr = new OutputStreamWriter(os, "UTF-8");

reader = new BufferedReader(isr);
writer = new PrintWriter(osr);
lg.info("Server: Initialisierung abgeschlossen");

lg.info("Server: warte auf Nachricht");

} catch (UnsupportedEncodingException ex) {
Logger.getLogger(Transmitter.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(Transmitter.class.getName()).log(Level.SEVERE, null, ex);
}
}

@Override @Override
public void run() { public void run() {
} }


@Override
public void onSubscribe(Flow.Subscription subscription) {
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}

@Override
public void onNext(String item) {
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}

@Override
public void onError(Throwable throwable) {
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}

@Override
public void onComplete() {
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}


} }

Loading…
Cancel
Save