mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-01-09 00:59:44 +03:00
[FEATURE] Доработка LauncherConfig для работы с nettyPort
This commit is contained in:
parent
0e215899e4
commit
9ca5158eeb
4 changed files with 41 additions and 1 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
dependencies {
|
||||
compile project(':libLauncher')
|
||||
compile 'javax.websocket:javax.websocket-client-api:1.1'
|
||||
compileOnly 'javax.websocket:javax.websocket-client-api:1.1'
|
||||
compileOnly 'com.google.guava:guava:26.0-jre'
|
||||
compile files('../compat/authlib/authlib-clean.jar')
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.RequestType;
|
||||
import ru.gravit.launcher.request.auth.AuthRequest.Result;
|
||||
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
|
||||
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||
|
@ -67,9 +69,26 @@ public AuthRequest(String login, byte[] encryptedPassword, HWID hwid, int auth_i
|
|||
public Integer getType() {
|
||||
return RequestType.AUTH.getNumber();
|
||||
}
|
||||
/*public class EchoRequest implements RequestInterface
|
||||
{
|
||||
String echo;
|
||||
|
||||
public EchoRequest(String echo) {
|
||||
this.echo = echo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "echo";
|
||||
}
|
||||
}*/
|
||||
@Override
|
||||
protected Result requestDo(HInput input, HOutput output) throws IOException {
|
||||
/*try {
|
||||
LegacyRequestBridge.sendRequest(new EchoRequest("Hello World!"));
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
output.writeString(login, SerializeLimits.MAX_LOGIN);
|
||||
output.writeBoolean(Launcher.profile != null);
|
||||
if (Launcher.profile != null)
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
package ru.gravit.launcher.request.websockets;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launcher.request.ResultInterface;
|
||||
|
||||
import javax.websocket.ContainerProvider;
|
||||
import javax.websocket.WebSocketContainer;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
public class LegacyRequestBridge {
|
||||
public static WaitEventHandler waitEventHandler = new WaitEventHandler();
|
||||
|
@ -23,4 +28,18 @@ public static ResultInterface sendRequest(RequestInterface request) throws IOExc
|
|||
waitEventHandler.requests.remove(e);
|
||||
return result;
|
||||
}
|
||||
public static void initWebSockets(String address, int port)
|
||||
{
|
||||
service = new ClientWebSocketService(new GsonBuilder());
|
||||
try {
|
||||
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
|
||||
container.connectToServer(service, new URI("ws://".concat(address).concat(":".concat(String.valueOf(port)).concat("/api"))));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
static {
|
||||
if(Launcher.getConfig().nettyPort != 0)
|
||||
initWebSockets(Launcher.getConfig().address.getHostName(),Launcher.getConfig().nettyPort);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ public static AutogenConfig getAutogenConfig() {
|
|||
// Instance
|
||||
@LauncherAPI
|
||||
public InetSocketAddress address;
|
||||
public int nettyPort;
|
||||
@LauncherAPI
|
||||
public final String projectname;
|
||||
public final int clientPort;
|
||||
|
@ -54,6 +55,7 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException
|
|||
isDownloadJava = config.isDownloadJava;
|
||||
isUsingWrapper = config.isUsingWrapper;
|
||||
isWarningMissArchJava = config.isWarningMissArchJava;
|
||||
nettyPort = config.nettyPort;
|
||||
LauncherEnvironment env;
|
||||
if (config.env == 0) env = LauncherEnvironment.DEV;
|
||||
else if (config.env == 1) env = LauncherEnvironment.DEBUG;
|
||||
|
|
Loading…
Reference in a new issue