1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
- package kommunikation.transmitter;
-
- import java.io.IOException;
- import java.io.ObjectInputStream;
- import java.io.ObjectOutputStream;
- import java.util.logging.Logger;
- import kommunikation.logger.OhmLogger;
-
-
-
- /**
- *
- * @author Alexander_Christoph
- */
- public abstract class Kommunikationspartner
- {
- protected static final Logger lg = OhmLogger.getLogger();
- protected int port;
- protected String ip;
- protected Object nachricht;
- protected Figur figur;
- protected ObjectInputStream in;
- protected ObjectOutputStream out;
-
- public Kommunikationspartner()
- {
- port = 35000;
- ip = "";
- }
-
- public abstract void verbinde();
-
- public void senden(Object nachricht)
- {
- try
- {
- out.writeObject(nachricht);
- }
- catch (IOException ex)
- {
- lg.severe(ex.toString());
- }
-
- lg.info("Grafik versendet");
- }
-
- public void empfangen()
- {
- try
- {
- lg.info("Warte auf Nachricht ...");
-
- nachricht = in.readObject();
-
- lg.info("Nachricht empfangen");
- }
- catch (IOException | ClassNotFoundException ex)
- {
- lg.severe(ex.toString());
- }
-
- }
-
- public Object getNachricht()
- {
- return nachricht;
- }
-
- public void setPort(int port)
- {
- this.port = port;
- lg.info("Port auf " + port + " gesetzt" );
- }
-
- public void setIp(String ip)
- {
- this.ip = ip;
- lg.info("Ip auf " + ip + " gesetzt" );
- }
- }
|