mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FIX] Фикс бага с ошибкой при восстановлении сессии
This commit is contained in:
parent
54c7526a66
commit
a540bdcf48
4 changed files with 40 additions and 23 deletions
|
@ -7,6 +7,7 @@
|
|||
import ru.gravit.launchserver.socket.Client;
|
||||
import ru.gravit.launchserver.websocket.WebSocketService;
|
||||
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -28,7 +29,13 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
|
|||
BatchProfileByUsernameRequestEvent result = new BatchProfileByUsernameRequestEvent();
|
||||
result.playerProfiles = new PlayerProfile[list.length];
|
||||
for (int i = 0; i < list.length; ++i) {
|
||||
UUID uuid = client.auth.handler.usernameToUUID(list[i].username);
|
||||
UUID uuid;
|
||||
if(client.auth == null)
|
||||
{
|
||||
LogHelper.warning("Client auth is null. Using default.");
|
||||
uuid = LaunchServer.server.config.getAuthProviderPair().handler.usernameToUUID(list[i].username);
|
||||
}
|
||||
else uuid = client.auth.handler.usernameToUUID(list[i].username);
|
||||
result.playerProfiles[i] = ProfileByUUIDResponse.getProfile(LaunchServer.server, uuid, list[i].username, list[i].client, client.auth.textureProvider);
|
||||
}
|
||||
service.sendObject(ctx, result);
|
||||
|
|
|
@ -48,7 +48,13 @@ public String getType() {
|
|||
|
||||
@Override
|
||||
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
|
||||
String username = client.auth.handler.uuidToUsername(uuid);
|
||||
String username;
|
||||
if(client.auth == null)
|
||||
{
|
||||
LogHelper.warning("Client auth is null. Using default.");
|
||||
username = LaunchServer.server.config.getAuthProviderPair().handler.uuidToUsername(uuid);
|
||||
}
|
||||
else username = client.auth.handler.uuidToUsername(uuid);
|
||||
service.sendObject(ctx, new ProfileByUUIDRequestEvent(getProfile(LaunchServer.server, uuid, username, this.client, client.auth.textureProvider)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
import ru.gravit.launchserver.socket.Client;
|
||||
import ru.gravit.launchserver.websocket.WebSocketService;
|
||||
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -22,7 +23,13 @@ public String getType() {
|
|||
|
||||
@Override
|
||||
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
|
||||
UUID uuid = client.auth.handler.usernameToUUID(username);
|
||||
UUID uuid;
|
||||
if(client.auth == null)
|
||||
{
|
||||
LogHelper.warning("Client auth is null. Using default.");
|
||||
uuid = LaunchServer.server.config.getAuthProviderPair().handler.usernameToUUID(username);
|
||||
}
|
||||
else uuid = client.auth.handler.usernameToUUID(username);
|
||||
service.sendObject(ctx, new ProfileByUsernameRequestEvent(getProfile(LaunchServer.server, uuid, username, this.client, client.auth.textureProvider)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -468,27 +468,24 @@ public static void main(String... args) throws Throwable {
|
|||
// Start client with WatchService monitoring
|
||||
boolean digest = !profile.isUpdateFastCheck();
|
||||
LogHelper.debug("Restore sessions");
|
||||
if(Launcher.getConfig().isNettyEnabled)
|
||||
RestoreSessionRequest request = new RestoreSessionRequest(Request.getSession());
|
||||
request.request();
|
||||
LegacyRequestBridge.service.reconnectCallback = () ->
|
||||
{
|
||||
RestoreSessionRequest request = new RestoreSessionRequest(Request.getSession());
|
||||
request.request();
|
||||
LegacyRequestBridge.service.reconnectCallback = () ->
|
||||
{
|
||||
LogHelper.debug("WebSocket connect closed. Try reconnect");
|
||||
try {
|
||||
if (!LegacyRequestBridge.service.reconnectBlocking()) LogHelper.error("Error connecting");
|
||||
LogHelper.debug("Connect to %s", Launcher.getConfig().address);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
RestoreSessionRequest request1 = new RestoreSessionRequest(Request.getSession());
|
||||
request1.request();
|
||||
} catch (Exception e) {
|
||||
LogHelper.error(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
LogHelper.debug("WebSocket connect closed. Try reconnect");
|
||||
try {
|
||||
if (!LegacyRequestBridge.service.reconnectBlocking()) LogHelper.error("Error connecting");
|
||||
LogHelper.debug("Connect to %s", Launcher.getConfig().address);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
RestoreSessionRequest request1 = new RestoreSessionRequest(Request.getSession());
|
||||
request1.request();
|
||||
} catch (Exception e) {
|
||||
LogHelper.error(e);
|
||||
}
|
||||
};
|
||||
LogHelper.debug("Starting JVM and client WatchService");
|
||||
FileNameMatcher assetMatcher = profile.getAssetUpdateMatcher();
|
||||
FileNameMatcher clientMatcher = profile.getClientUpdateMatcher();
|
||||
|
|
Loading…
Reference in a new issue