Changed Server to new protocol on port 9999 with only one String based
communication exchange
This commit is contained in:
parent
141374eee3
commit
c4ed32689d
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,4 @@
|
||||||
#Sun Apr 14 19:07:39 CEST 2019
|
#Mon Apr 15 11:05:55 CEST 2019
|
||||||
Load-File-on-startup=true
|
Load-File-on-startup=true
|
||||||
key2=44
|
key2=44
|
||||||
key1=29
|
key1=29
|
||||||
|
|
|
@ -31,7 +31,6 @@ public class BasicGuiApp extends Application{
|
||||||
public static KeyChecker listener;
|
public static KeyChecker listener;
|
||||||
|
|
||||||
public BasicGuiApp(){
|
public BasicGuiApp(){
|
||||||
|
|
||||||
ModLoader ml = new ModLoader();
|
ModLoader ml = new ModLoader();
|
||||||
ml.init();
|
ml.init();
|
||||||
ml.addMods();
|
ml.addMods();
|
||||||
|
@ -45,7 +44,6 @@ public class BasicGuiApp extends Application{
|
||||||
}
|
}
|
||||||
listener = new KeyChecker();
|
listener = new KeyChecker();
|
||||||
LogManager.getLogManager().reset();
|
LogManager.getLogManager().reset();
|
||||||
|
|
||||||
Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
|
Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
|
||||||
logger.setLevel(Level.OFF);
|
logger.setLevel(Level.OFF);
|
||||||
GlobalScreen.addNativeKeyListener(listener);
|
GlobalScreen.addNativeKeyListener(listener);
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class UpdateChecker {
|
||||||
public void requestServerData(){
|
public void requestServerData(){
|
||||||
try {
|
try {
|
||||||
Socket socket = new Socket();
|
Socket socket = new Socket();
|
||||||
socket.connect(new InetSocketAddress(InetAddress.getByName("cookiestudios.org"), 9999), 700);
|
socket.connect(new InetSocketAddress(InetAddress.getByName("cookiestudios.org"), 9999), 2000);
|
||||||
DataInputStream in = new DataInputStream(socket.getInputStream());
|
DataInputStream in = new DataInputStream(socket.getInputStream());
|
||||||
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
|
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ public class UpdateChecker {
|
||||||
String[] keyValue = str.split("=");
|
String[] keyValue = str.split("=");
|
||||||
serverData.put(keyValue[0], keyValue[1]);
|
serverData.put(keyValue[0], keyValue[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.close();
|
socket.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.nio.channels.ReadableByteChannel;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import guis.MainGui;
|
import guis.MainGui;
|
||||||
|
import javafx.application.Platform;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.control.Alert.AlertType;
|
import javafx.scene.control.Alert.AlertType;
|
||||||
import javafx.scene.control.ButtonType;
|
import javafx.scene.control.ButtonType;
|
||||||
|
@ -22,37 +23,42 @@ public class Updater {
|
||||||
uc.requestServerData();
|
uc.requestServerData();
|
||||||
System.out.println("got version: " + uc.getLatestVersion());
|
System.out.println("got version: " + uc.getLatestVersion());
|
||||||
if(uc.getLatestVersion() > Start.VERSION){
|
if(uc.getLatestVersion() > Start.VERSION){
|
||||||
String dl = "https://cookiestudios.org/software/QuickLaunch/QuickLaunch.jar";
|
Platform.runLater(new Runnable() {
|
||||||
Alert updateAlert = new Alert(AlertType.INFORMATION,
|
@Override
|
||||||
|
public void run() {
|
||||||
|
String dl = "https://cookiestudios.org/software/QuickLaunch/QuickLaunch.jar";
|
||||||
|
Alert updateAlert = new Alert(AlertType.INFORMATION,
|
||||||
"There is a newer version of QuickLaunch available\nDownload now?",
|
"There is a newer version of QuickLaunch available\nDownload now?",
|
||||||
ButtonType.YES,
|
ButtonType.YES,
|
||||||
ButtonType.NO);
|
ButtonType.NO);
|
||||||
updateAlert.setTitle("Update available!");
|
updateAlert.setTitle("Update available!");
|
||||||
Optional<ButtonType> result = updateAlert.showAndWait();
|
Optional<ButtonType> result = updateAlert.showAndWait();
|
||||||
if(result.isPresent() && result.get() == ButtonType.YES){
|
if(result.isPresent() && result.get() == ButtonType.YES){
|
||||||
try {
|
try {
|
||||||
System.out.println("here");
|
System.out.println("here");
|
||||||
cleanDirectory();
|
cleanDirectory();
|
||||||
URL website = new URL(dl);
|
URL website = new URL(dl);
|
||||||
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
|
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
|
||||||
FileOutputStream fos = new FileOutputStream(SettingManager.getJarDirectory()+File.separator+"Squirrel.jar");
|
FileOutputStream fos = new FileOutputStream(SettingManager.getJarDirectory()+File.separator+"Squirrel.jar");
|
||||||
fos.getChannel().transferFrom(rbc, 0, Integer.MAX_VALUE);
|
fos.getChannel().transferFrom(rbc, 0, Integer.MAX_VALUE);
|
||||||
fos.close();
|
fos.close();
|
||||||
try {
|
try {
|
||||||
ProcessBuilder pb = new ProcessBuilder("java","-jar",SettingManager.getJarDirectory()+File.separator+"Squirrel.jar");
|
ProcessBuilder pb = new ProcessBuilder("java","-jar",SettingManager.getJarDirectory()+File.separator+"Squirrel.jar");
|
||||||
pb.directory(new File(SettingManager.getJarDirectory()));
|
pb.directory(new File(SettingManager.getJarDirectory()));
|
||||||
pb.redirectErrorStream(true);
|
pb.redirectErrorStream(true);
|
||||||
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
|
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
|
||||||
pb.start();
|
pb.start();
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
System.exit(0);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
MainGui.addNotification("Couldn't download update", 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
System.exit(0);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
MainGui.addNotification("Couldn't download update", 2);
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
} else{
|
} else{
|
||||||
if(uc.getLatestVersion() == Start.VERSION){
|
if(uc.getLatestVersion() == Start.VERSION){
|
||||||
MainGui.addNotification("QuickLaunch is up to date", 2);
|
MainGui.addNotification("QuickLaunch is up to date", 2);
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -15,7 +15,6 @@ implements Runnable {
|
||||||
this.PORT = port;
|
this.PORT = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean updateNeeded = true;
|
|
||||||
ServerSocket ses;
|
ServerSocket ses;
|
||||||
Socket s;
|
Socket s;
|
||||||
DataOutputStream out;
|
DataOutputStream out;
|
||||||
|
@ -25,25 +24,14 @@ implements Runnable {
|
||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
do {
|
do {
|
||||||
updateNeeded = true;
|
|
||||||
ses = new ServerSocket(this.PORT);
|
ses = new ServerSocket(this.PORT);
|
||||||
s = ses.accept();
|
s = ses.accept();
|
||||||
System.out.println("Connected with: " + s.getInetAddress());
|
System.out.println("Connected with: " + s.getInetAddress());
|
||||||
out = new DataOutputStream(s.getOutputStream());
|
out = new DataOutputStream(s.getOutputStream());
|
||||||
in = new DataInputStream(s.getInputStream());
|
in = new DataInputStream(s.getInputStream());
|
||||||
out.writeFloat(Start.version);
|
System.out.println(in.readUTF());
|
||||||
|
out.writeUTF("VERSION="+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();
|
out.close();
|
||||||
in.close();
|
in.close();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
|
@ -6,7 +6,6 @@ import run.UpdateThread;
|
||||||
|
|
||||||
public class Start {
|
public class Start {
|
||||||
public static float version = -1.0f;
|
public static float version = -1.0f;
|
||||||
public static String download = "";
|
|
||||||
|
|
||||||
private static final int PORT = 9999;
|
private static final int PORT = 9999;
|
||||||
|
|
||||||
|
@ -14,7 +13,6 @@ public class Start {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
version = Float.parseFloat(JOptionPane.showInputDialog("QuickLaunch version:"));
|
version = Float.parseFloat(JOptionPane.showInputDialog("QuickLaunch version:"));
|
||||||
download = JOptionPane.showInputDialog("Link to downloadable");
|
|
||||||
Thread ut = new Thread(new UpdateThread());
|
Thread ut = new Thread(new UpdateThread());
|
||||||
ut.start();
|
ut.start();
|
||||||
System.out.println("Update thread started");
|
System.out.println("Update thread started");
|
||||||
|
|
|
@ -9,7 +9,6 @@ implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
do {
|
do {
|
||||||
Start.version = Float.parseFloat(JOptionPane.showInputDialog("QuickLaunch version (" + Start.version + "): "));
|
Start.version = Float.parseFloat(JOptionPane.showInputDialog("QuickLaunch version (" + Start.version + "): "));
|
||||||
Start.download = JOptionPane.showInputDialog("Link to downloadable:");
|
|
||||||
} while (true);
|
} while (true);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue