Changed Server to new protocol on port 9999 with only one String based

communication exchange
This commit is contained in:
2019-04-15 11:14:06 +02:00
parent 141374eee3
commit c4ed32689d
14 changed files with 36 additions and 48 deletions

View File

@@ -14,7 +14,7 @@ public class UpdateChecker {
public void requestServerData(){
try {
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());
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
@@ -30,7 +30,6 @@ public class UpdateChecker {
String[] keyValue = str.split("=");
serverData.put(keyValue[0], keyValue[1]);
}
socket.close();
} catch (IOException e) {
e.printStackTrace();

View File

@@ -9,6 +9,7 @@ import java.nio.channels.ReadableByteChannel;
import java.util.Optional;
import guis.MainGui;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonType;
@@ -22,37 +23,42 @@ public class Updater {
uc.requestServerData();
System.out.println("got version: " + uc.getLatestVersion());
if(uc.getLatestVersion() > Start.VERSION){
String dl = "https://cookiestudios.org/software/QuickLaunch/QuickLaunch.jar";
Alert updateAlert = new Alert(AlertType.INFORMATION,
Platform.runLater(new Runnable() {
@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?",
ButtonType.YES,
ButtonType.NO);
updateAlert.setTitle("Update available!");
Optional<ButtonType> result = updateAlert.showAndWait();
if(result.isPresent() && result.get() == ButtonType.YES){
try {
System.out.println("here");
cleanDirectory();
URL website = new URL(dl);
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(SettingManager.getJarDirectory()+File.separator+"Squirrel.jar");
fos.getChannel().transferFrom(rbc, 0, Integer.MAX_VALUE);
fos.close();
try {
ProcessBuilder pb = new ProcessBuilder("java","-jar",SettingManager.getJarDirectory()+File.separator+"Squirrel.jar");
pb.directory(new File(SettingManager.getJarDirectory()));
pb.redirectErrorStream(true);
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
pb.start();
}catch(Exception e) {
e.printStackTrace();
updateAlert.setTitle("Update available!");
Optional<ButtonType> result = updateAlert.showAndWait();
if(result.isPresent() && result.get() == ButtonType.YES){
try {
System.out.println("here");
cleanDirectory();
URL website = new URL(dl);
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(SettingManager.getJarDirectory()+File.separator+"Squirrel.jar");
fos.getChannel().transferFrom(rbc, 0, Integer.MAX_VALUE);
fos.close();
try {
ProcessBuilder pb = new ProcessBuilder("java","-jar",SettingManager.getJarDirectory()+File.separator+"Squirrel.jar");
pb.directory(new File(SettingManager.getJarDirectory()));
pb.redirectErrorStream(true);
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
pb.start();
}catch(Exception e) {
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{
if(uc.getLatestVersion() == Start.VERSION){
MainGui.addNotification("QuickLaunch is up to date", 2);