Improved Backend

This commit is contained in:
2019-04-28 11:19:53 +02:00
parent c4ed32689d
commit 02e63e14c0
29 changed files with 175 additions and 42 deletions

View File

@@ -1,55 +0,0 @@
package run;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import run.Start;
public class ServerThread
implements Runnable {
int PORT;
public ServerThread(int port) {
this.PORT = port;
}
ServerSocket ses;
Socket s;
DataOutputStream out;
DataInputStream in;
public void run() {
do {
try {
do {
ses = new ServerSocket(this.PORT);
s = ses.accept();
System.out.println("Connected with: " + s.getInetAddress());
out = new DataOutputStream(s.getOutputStream());
in = new DataInputStream(s.getInputStream());
System.out.println(in.readUTF());
out.writeUTF("VERSION="+Start.version);
out.close();
in.close();
s.close();
ses.close();
} while (true);
}
catch (IOException io) {
io.printStackTrace();
try {
out.close();
in.close();
s.close();
ses.close();
} catch (IOException e) {
e.printStackTrace();
System.out.println("Server panic");
}
}
} while (true);
}
}

View File

@@ -1,23 +1,12 @@
package run;
import javax.swing.JOptionPane;
import run.ServerThread;
import run.UpdateThread;
import javafx.application.Application;
import stages.AppStage;
public class Start {
public static float version = -1.0f;
private static final int PORT = 9999;
public static void main(String[] args) {
version = Float.parseFloat(JOptionPane.showInputDialog("QuickLaunch version:"));
Thread ut = new Thread(new UpdateThread());
ut.start();
System.out.println("Update thread started");
Thread st = new Thread(new ServerThread(PORT));
st.start();
System.out.println("Server listening");
Application.launch(AppStage.class);
}
}

View File

@@ -1,14 +0,0 @@
package run;
import javax.swing.JOptionPane;
import run.Start;
public class UpdateThread
implements Runnable {
@Override
public void run() {
do {
Start.version = Float.parseFloat(JOptionPane.showInputDialog("QuickLaunch version (" + Start.version + "): "));
} while (true);
}
}