Improved Backend
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user