Use existing sessionid on login if available

This commit is contained in:
Adam
2019-01-28 08:59:57 -05:00
parent 63c3937f87
commit c62941855d
4 changed files with 9 additions and 5 deletions

View File

@@ -56,6 +56,7 @@ public class AccountClient
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("account")
.addPathSegment("login")
.addQueryParameter("uuid", uuid.toString())
.build();
logger.debug("Built URI: {}", url);

View File

@@ -136,10 +136,8 @@ public class AccountService
}
@RequestMapping("/login")
public OAuthResponse login()
public OAuthResponse login(@RequestParam UUID uuid)
{
UUID uuid = UUID.randomUUID();
State state = new State();
state.setUuid(uuid);
state.setApiVersion(RuneLiteAPI.getVersion());

View File

@@ -31,6 +31,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.time.Instant;
import java.util.UUID;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.Getter;
@@ -59,7 +60,6 @@ public class SessionManager
private final EventBus eventBus;
private final ConfigManager configManager;
private final WSClient wsClient;
private final AccountClient loginClient = new AccountClient();
@Inject
private SessionManager(ConfigManager configManager, EventBus eventBus, WSClient wsClient)
@@ -184,6 +184,10 @@ public class SessionManager
public void login()
{
// If a session is already open, use that id. Otherwise generate a new id.
UUID uuid = wsClient.getSessionId() != null ? wsClient.getSessionId() : UUID.randomUUID();
AccountClient loginClient = new AccountClient(uuid);
final OAuthResponse login;
try

View File

@@ -25,13 +25,13 @@
package net.runelite.client.ws;
import com.google.gson.Gson;
import java.time.Duration;
import java.util.Collection;
import java.util.HashSet;
import java.util.Objects;
import java.util.UUID;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.client.eventbus.EventBus;
import net.runelite.http.api.RuneLiteAPI;
@@ -52,6 +52,7 @@ public class WSClient extends WebSocketListener implements AutoCloseable
private final Collection<Class<? extends WebsocketMessage>> messages = new HashSet<>();
private volatile Gson gson;
@Getter
private UUID sessionId;
private WebSocket webSocket;