Transmitter als Abstrakte Klasse
This commit is contained in:
parent
83ddb02477
commit
320c6041b7
@ -4,16 +4,35 @@
|
|||||||
*/
|
*/
|
||||||
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{
|
public abstract class Transmitter implements Runnable, Subscriber<String> {
|
||||||
static final int timeout = 10000;
|
|
||||||
|
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() {
|
||||||
|
|
||||||
@ -21,9 +40,50 @@ public abstract class Transmitter implements Runnable{
|
|||||||
|
|
||||||
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…
x
Reference in New Issue
Block a user