Skip to content
Snippets Groups Projects
Commit f38a8e37 authored by Lukas Friedrichsen's avatar Lukas Friedrichsen
Browse files

connection can be established now

parent eb4762b1
Branches
No related tags found
No related merge requests found
/server/
/gui/
File deleted
No preview for this file type
......@@ -323,6 +323,21 @@ public class MainApp extends Application {
}
}
else {
(new Thread(new EstablishConnection(this))).start();;
}
}
class EstablishConnection implements Runnable {
private final MainApp CONTROLLER_INSTANCE;
EstablishConnection (MainApp controller) {
CONTROLLER_INSTANCE = controller;
}
@Override
public void run() {
if (!connectionEstablished) {
try (Socket socket = new Socket(configuration.getSocketAddress().get().getHostName(), configuration.getSocketAddress().get().getPort())) {
client = socket;
client.setKeepAlive(true);
......@@ -330,22 +345,26 @@ public class MainApp extends Application {
in = client.getInputStream();
out = client.getOutputStream();
connectionEstablished = true;
setStatus("Verbindung zu "+client.getRemoteSocketAddress()+" aufgebaut!");
(new updateThread(this, in)).run();
//setStatus("Verbindung zu "+client.getRemoteSocketAddress()+" aufgebaut!");
//(new Thread(new UpdateFunctionality(CONTROLLER_INSTANCE, in))).start();
while (connectionEstablished) {
}
}
catch (Exception e) {
setStatus("Error at: establishConnection (establishing connection");
//setStatus("Error at: establishConnection (establishing connection");
e.printStackTrace();
}
}
}
}
class updateThread implements Runnable {
class UpdateFunctionality implements Runnable {
private final MainApp CONTROLLER_INSTANCE;
private final BufferedInputStream INPUT_STREAM;
updateThread (MainApp controller, InputStream in) {
UpdateFunctionality (MainApp controller, InputStream in) {
CONTROLLER_INSTANCE = controller;
INPUT_STREAM = new BufferedInputStream(in, Properties.OUT_BUFFER_SIZE);
}
......@@ -385,6 +404,7 @@ public class MainApp extends Application {
}
}
}
Thread.yield();
}
}
catch (Exception e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment