Browse Source

fast fast fertig

master
Apollo 5 years ago
parent
commit
c2de03caff
3 changed files with 22 additions and 3 deletions
  1. 2
    1
      src/chatprogramm/Start.java
  2. 9
    0
      src/controller/ConnectController.java
  3. 11
    2
      src/model/Transmitter.java

+ 2
- 1
src/chatprogramm/Start.java View File

ReceiveAdapter adapter = new ReceiveAdapter(view,model); ReceiveAdapter adapter = new ReceiveAdapter(view,model);
adapter.registerEvents(); adapter.registerEvents();
view.setSize(800,600);
view.setLocationRelativeTo(null);
view.setVisible(true); view.setVisible(true);
} }

+ 9
- 0
src/controller/ConnectController.java View File

{ {
ChatView view; ChatView view;
Transmitter model; Transmitter model;
int modus;
public ConnectController(ChatView view,Transmitter model,int modus) public ConnectController(ChatView view,Transmitter model,int modus)
{ {
this.view = view; this.view = view;
this.model = model; this.model = model;
this.modus = modus;
if(modus==0) if(modus==0)
{ {
Thread chatter = new Thread(model); Thread chatter = new Thread(model);
@Override @Override
public void actionPerformed(ActionEvent arg0) public void actionPerformed(ActionEvent arg0)
{ {
if(modus == 1)
{
model.setIP_ADRESSE(view.getTxtzielIP().getText()); model.setIP_ADRESSE(view.getTxtzielIP().getText());
Thread chatter = new Thread(model); Thread chatter = new Thread(model);
chatter.start(); chatter.start();
}
else
{
view.getChatanzeige().setText("Server kann sich nicht verbinden");
}
} }
} }

+ 11
- 2
src/model/Transmitter.java View File

{ {
private static final Logger lg = OhmLogger.getLogger(); private static final Logger lg = OhmLogger.getLogger();
private static final int PORT = 35000; private static final int PORT = 35000;
private String IP_ADRESSE = "127.0.0.1";
private String IP_ADRESSE = "";


int modus; int modus;
private String nachricht; private String nachricht;
{ {
sSocket = new ServerSocket(PORT); sSocket = new ServerSocket(PORT);
lg.info("Server: Warte auf Verbindung ..."); lg.info("Server: Warte auf Verbindung ...");
nachricht = "Server: Warte auf Verbindung ...";
setChanged();
notifyObservers();
s = sSocket.accept(); // Achtung: blockiert! s = sSocket.accept(); // Achtung: blockiert!
nachricht = "Verbunden mit Client";
setChanged();
notifyObservers();
lg.info("Server: Verbindung akzeptiert"); lg.info("Server: Verbindung akzeptiert");
} }
catch (IOException ex) catch (IOException ex)
} }
} }
else if (modus == 1) else if (modus == 1)
{
{
nachricht = "Verbinden mit "+ IP_ADRESSE;
setChanged();
notifyObservers();
lg.info("Client: verbinde ..."); lg.info("Client: verbinde ...");
try try
{ {

Loading…
Cancel
Save