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
 | 
			
		||||
key2=44
 | 
			
		||||
key1=29
 | 
			
		||||
 | 
			
		||||
@ -31,7 +31,6 @@ public class BasicGuiApp extends Application{
 | 
			
		||||
	public static KeyChecker listener;
 | 
			
		||||
	
 | 
			
		||||
	public BasicGuiApp(){
 | 
			
		||||
		
 | 
			
		||||
		ModLoader ml = new ModLoader();
 | 
			
		||||
		ml.init();
 | 
			
		||||
		ml.addMods();
 | 
			
		||||
@ -45,7 +44,6 @@ public class BasicGuiApp extends Application{
 | 
			
		||||
		}
 | 
			
		||||
		listener = new KeyChecker();
 | 
			
		||||
		LogManager.getLogManager().reset();
 | 
			
		||||
 | 
			
		||||
		Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
 | 
			
		||||
		logger.setLevel(Level.OFF);
 | 
			
		||||
		GlobalScreen.addNativeKeyListener(listener);
 | 
			
		||||
 | 
			
		||||
@ -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();
 | 
			
		||||
 | 
			
		||||
@ -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,6 +23,9 @@ public class Updater {
 | 
			
		||||
		uc.requestServerData();
 | 
			
		||||
		System.out.println("got version: " + uc.getLatestVersion());    		
 | 
			
		||||
		if(uc.getLatestVersion() > Start.VERSION){
 | 
			
		||||
			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?",
 | 
			
		||||
@ -53,6 +57,8 @@ public class Updater {
 | 
			
		||||
							MainGui.addNotification("Couldn't download update", 2);
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			});
 | 
			
		||||
		} else{
 | 
			
		||||
			if(uc.getLatestVersion() == Start.VERSION){
 | 
			
		||||
				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;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    boolean updateNeeded = true;
 | 
			
		||||
    ServerSocket ses;
 | 
			
		||||
    Socket s;
 | 
			
		||||
    DataOutputStream out;
 | 
			
		||||
@ -25,25 +24,14 @@ implements Runnable {
 | 
			
		||||
        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());
 | 
			
		||||
                    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();
 | 
			
		||||
                    in.close();
 | 
			
		||||
                    s.close();
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,6 @@ import run.UpdateThread;
 | 
			
		||||
 | 
			
		||||
public class Start {
 | 
			
		||||
    public static float version = -1.0f;
 | 
			
		||||
    public static String download = "";
 | 
			
		||||
    
 | 
			
		||||
    private static final int PORT = 9999;
 | 
			
		||||
    
 | 
			
		||||
@ -14,7 +13,6 @@ public class Start {
 | 
			
		||||
    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");
 | 
			
		||||
 | 
			
		||||
@ -9,7 +9,6 @@ implements Runnable {
 | 
			
		||||
    public void run() {
 | 
			
		||||
        do {
 | 
			
		||||
            Start.version = Float.parseFloat(JOptionPane.showInputDialog("QuickLaunch version (" + Start.version + "): "));
 | 
			
		||||
            Start.download = JOptionPane.showInputDialog("Link to downloadable:");
 | 
			
		||||
        } while (true);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user