mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FIX] Исправлена гонка потоков, исправлен reconnect loop, пофикшен вывод ошибок
This commit is contained in:
parent
a921fde598
commit
edc5f1f7b2
5 changed files with 19 additions and 17 deletions
|
@ -9,6 +9,7 @@
|
|||
import ru.gravit.launcher.managers.ClientGsonManager;
|
||||
import ru.gravit.launcher.managers.ConsoleManager;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.RequestException;
|
||||
import ru.gravit.launcher.request.auth.RestoreSessionRequest;
|
||||
import ru.gravit.launcher.request.websockets.StandartClientWebSocketService;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
|
@ -84,7 +85,8 @@ public void start(String... args) throws Throwable {
|
|||
Request.service.open();
|
||||
LogHelper.debug("Connect to %s", Launcher.getConfig().address);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogHelper.error(e);
|
||||
throw new RequestException(String.format("Connect error: %s", e.getMessage() != null ? e.getMessage() : "null"));
|
||||
}
|
||||
try {
|
||||
RestoreSessionRequest request1 = new RestoreSessionRequest(Request.getSession());
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
import ru.gravit.launcher.profiles.ClientProfile;
|
||||
import ru.gravit.launcher.profiles.PlayerProfile;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.RequestException;
|
||||
import ru.gravit.launcher.request.auth.RestoreSessionRequest;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
|
@ -462,7 +463,8 @@ public static void main(String... args) throws Throwable {
|
|||
Request.service.open();
|
||||
LogHelper.debug("Connect to %s", Launcher.getConfig().address);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogHelper.error(e);
|
||||
throw new RequestException(String.format("Connect error: %s", e.getMessage() != null ? e.getMessage() : "null"));
|
||||
}
|
||||
try {
|
||||
RestoreSessionRequest request1 = new RestoreSessionRequest(Request.getSession());
|
||||
|
|
|
@ -35,14 +35,6 @@ public ClientJSONPoint(final String uri) throws SSLException {
|
|||
|
||||
public ClientJSONPoint(URI uri) throws SSLException {
|
||||
this.uri = uri;
|
||||
// Connect with V13 (RFC 6455 aka HyBi-17). You can change it to V08 or V00.
|
||||
// If you change it to V00, ping is not supported and remember to change
|
||||
// HttpResponseDecoder to WebSocketHttpResponseDecoder in the pipeline.
|
||||
webSocketClientHandler =
|
||||
new WebSocketClientHandler(
|
||||
WebSocketClientHandshakerFactory.newHandshaker(
|
||||
uri, WebSocketVersion.V13, null, false, EmptyHttpHeaders.INSTANCE, 1280000), this);
|
||||
|
||||
String protocol = uri.getScheme();
|
||||
if (!"ws".equals(protocol) && !"wss".equals(protocol)) {
|
||||
throw new IllegalArgumentException("Unsupported protocol: " + protocol);
|
||||
|
@ -74,6 +66,10 @@ public void initChannel(SocketChannel ch) throws Exception {
|
|||
|
||||
public void open() throws Exception {
|
||||
//System.out.println("WebSocket Client connecting");
|
||||
webSocketClientHandler =
|
||||
new WebSocketClientHandler(
|
||||
WebSocketClientHandshakerFactory.newHandshaker(
|
||||
uri, WebSocketVersion.V13, null, false, EmptyHttpHeaders.INSTANCE, 1280000), this);
|
||||
ch = bootstrap.connect(uri.getHost(), uri.getPort()).sync().channel();
|
||||
webSocketClientHandler.handshakeFuture().sync();
|
||||
}
|
||||
|
@ -89,8 +85,12 @@ public ChannelFuture send(String text)
|
|||
public void close() throws InterruptedException {
|
||||
//System.out.println("WebSocket Client sending close");
|
||||
isClosed = true;
|
||||
ch.writeAndFlush(new CloseWebSocketFrame());
|
||||
ch.closeFuture().sync();
|
||||
if(ch != null && ch.isActive())
|
||||
{
|
||||
ch.writeAndFlush(new CloseWebSocketFrame());
|
||||
ch.closeFuture().sync();
|
||||
}
|
||||
|
||||
//group.shutdownGracefully();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,10 +14,6 @@
|
|||
import io.netty.handler.codec.http.websocketx.WebSocketFrame;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
/**
|
||||
* @author Stephen Mallette (http://stephen.genoprime.com)
|
||||
*/
|
||||
public class WebSocketClientHandler extends SimpleChannelInboundHandler<Object> {
|
||||
|
||||
private final WebSocketClientHandshaker handshaker;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
import ru.gravit.launcher.events.request.ProfilesRequestEvent;
|
||||
import ru.gravit.launcher.profiles.ClientProfile;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.RequestException;
|
||||
import ru.gravit.launcher.request.auth.AuthRequest;
|
||||
import ru.gravit.launcher.request.update.ProfilesRequest;
|
||||
import ru.gravit.launcher.server.setup.ServerWrapperSetup;
|
||||
|
@ -165,7 +166,8 @@ public void run(String... args) throws Throwable {
|
|||
Request.service.open();
|
||||
LogHelper.debug("Connect to %s", config.websocket.address);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogHelper.error(e);
|
||||
throw new RequestException(String.format("Connect error: %s", e.getMessage() != null ? e.getMessage() : "null"));
|
||||
}
|
||||
auth();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue