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

@@ -46,7 +46,8 @@ public class Start
ReceiveAdapter adapter = new ReceiveAdapter(view,model);
adapter.registerEvents();
view.setSize(800,600);
view.setLocationRelativeTo(null);
view.setVisible(true);
}

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

@@ -23,11 +23,13 @@ public class ConnectController implements ActionListener
{
ChatView view;
Transmitter model;
int modus;
public ConnectController(ChatView view,Transmitter model,int modus)
{
this.view = view;
this.model = model;
this.modus = modus;
if(modus==0)
{
Thread chatter = new Thread(model);
@@ -52,8 +54,15 @@ public class ConnectController implements ActionListener
@Override
public void actionPerformed(ActionEvent arg0)
{
if(modus == 1)
{
model.setIP_ADRESSE(view.getTxtzielIP().getText());
Thread chatter = new Thread(model);
chatter.start();
}
else
{
view.getChatanzeige().setText("Server kann sich nicht verbinden");
}
}
}

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

@@ -27,7 +27,7 @@ public class Transmitter extends Observable implements Runnable
{
private static final Logger lg = OhmLogger.getLogger();
private static final int PORT = 35000;
private String IP_ADRESSE = "127.0.0.1";
private String IP_ADRESSE = "";

int modus;
private String nachricht;
@@ -56,7 +56,13 @@ public class Transmitter extends Observable implements Runnable
{
sSocket = new ServerSocket(PORT);
lg.info("Server: Warte auf Verbindung ...");
nachricht = "Server: Warte auf Verbindung ...";
setChanged();
notifyObservers();
s = sSocket.accept(); // Achtung: blockiert!
nachricht = "Verbunden mit Client";
setChanged();
notifyObservers();
lg.info("Server: Verbindung akzeptiert");
}
catch (IOException ex)
@@ -65,7 +71,10 @@ public class Transmitter extends Observable implements Runnable
}
}
else if (modus == 1)
{
{
nachricht = "Verbinden mit "+ IP_ADRESSE;
setChanged();
notifyObservers();
lg.info("Client: verbinde ...");
try
{

Loading…
Cancel
Save