mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
[FIX] Попытка реализации автообновления с вебсокетами
This commit is contained in:
parent
a83754e7f1
commit
f750e8897a
3 changed files with 20 additions and 4 deletions
|
@ -185,6 +185,8 @@ public class NettyConfig
|
||||||
{
|
{
|
||||||
public String bindAddress;
|
public String bindAddress;
|
||||||
public int port;
|
public int port;
|
||||||
|
public String launcherURL;
|
||||||
|
public String launcherEXEURL;
|
||||||
}
|
}
|
||||||
public class GuardLicenseConf
|
public class GuardLicenseConf
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,8 +17,8 @@ public class LauncherResponse implements JsonResponseInterface {
|
||||||
public byte[] digest;
|
public byte[] digest;
|
||||||
public int launcher_type;
|
public int launcher_type;
|
||||||
//REPLACED TO REAL URL
|
//REPLACED TO REAL URL
|
||||||
public static final String JAR_URL = "http://localhost:9752/Launcher.jar";
|
public static final String JAR_URL = LaunchServer.server.config.netty.launcherURL;
|
||||||
public static final String EXE_URL = "http://localhost:9752/Launcher.exe";
|
public static final String EXE_URL = LaunchServer.server.config.netty.launcherEXEURL;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
import ru.gravit.utils.helper.SecurityHelper;
|
import ru.gravit.utils.helper.SecurityHelper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -46,7 +50,16 @@ public static void update(LauncherConfig config, LauncherRequestEvent result) th
|
||||||
builder.inheritIO();
|
builder.inheritIO();
|
||||||
|
|
||||||
// Rewrite and start new instance
|
// Rewrite and start new instance
|
||||||
IOHelper.write(BINARY_PATH, result.binary);
|
if(result.binary != null)
|
||||||
|
IOHelper.write(BINARY_PATH, result.binary);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
URLConnection connection = IOHelper.newConnection(new URL(result.url));
|
||||||
|
connection.connect();
|
||||||
|
try(OutputStream stream = connection.getOutputStream()) {
|
||||||
|
IOHelper.transfer(BINARY_PATH, stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
builder.start();
|
builder.start();
|
||||||
|
|
||||||
// Kill current instance
|
// Kill current instance
|
||||||
|
@ -62,7 +75,8 @@ public LauncherRequest() {
|
||||||
@Override
|
@Override
|
||||||
public LauncherRequestEvent requestWebSockets() throws Exception
|
public LauncherRequestEvent requestWebSockets() throws Exception
|
||||||
{
|
{
|
||||||
return (LauncherRequestEvent) LegacyRequestBridge.sendRequest(this);
|
LauncherRequestEvent result = (LauncherRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
|
|
Loading…
Reference in a new issue