Initial git commit
This commit is contained in:
67
QuickLaunchUpdateServer/src/run/ServerThread.java
Normal file
67
QuickLaunchUpdateServer/src/run/ServerThread.java
Normal file
@@ -0,0 +1,67 @@
|
||||
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;
|
||||
}
|
||||
|
||||
boolean updateNeeded = true;
|
||||
ServerSocket ses;
|
||||
Socket s;
|
||||
DataOutputStream out;
|
||||
DataInputStream in;
|
||||
|
||||
public void run() {
|
||||
do {
|
||||
try {
|
||||
do {
|
||||
updateNeeded = true;
|
||||
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());
|
||||
out.writeFloat(Start.version);
|
||||
|
||||
System.out.println(in.readUTF());
|
||||
System.out.println(in.readUTF());
|
||||
System.out.println(in.readUTF());
|
||||
System.out.println(in.readUTF());
|
||||
|
||||
updateNeeded = in.readBoolean();
|
||||
|
||||
if (updateNeeded) {
|
||||
System.out.println("Update needed, Download link was send");
|
||||
out.writeUTF(Start.download);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
25
QuickLaunchUpdateServer/src/run/Start.java
Normal file
25
QuickLaunchUpdateServer/src/run/Start.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package run;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import run.ServerThread;
|
||||
import run.UpdateThread;
|
||||
|
||||
public class Start {
|
||||
public static float version = -1.0f;
|
||||
public static String download = "";
|
||||
|
||||
private static final int PORT = 9999;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
version = Float.parseFloat(JOptionPane.showInputDialog("QuickLaunch version:"));
|
||||
download = JOptionPane.showInputDialog("Link to downloadable");
|
||||
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");
|
||||
}
|
||||
}
|
||||
15
QuickLaunchUpdateServer/src/run/UpdateThread.java
Normal file
15
QuickLaunchUpdateServer/src/run/UpdateThread.java
Normal file
@@ -0,0 +1,15 @@
|
||||
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 + "): "));
|
||||
Start.download = JOptionPane.showInputDialog("Link to downloadable:");
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user