Use existing sessionid on login if available
This commit is contained in:
@@ -56,6 +56,7 @@ public class AccountClient
|
|||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
||||||
.addPathSegment("account")
|
.addPathSegment("account")
|
||||||
.addPathSegment("login")
|
.addPathSegment("login")
|
||||||
|
.addQueryParameter("uuid", uuid.toString())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
logger.debug("Built URI: {}", url);
|
logger.debug("Built URI: {}", url);
|
||||||
|
|||||||
@@ -136,10 +136,8 @@ public class AccountService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/login")
|
@RequestMapping("/login")
|
||||||
public OAuthResponse login()
|
public OAuthResponse login(@RequestParam UUID uuid)
|
||||||
{
|
{
|
||||||
UUID uuid = UUID.randomUUID();
|
|
||||||
|
|
||||||
State state = new State();
|
State state = new State();
|
||||||
state.setUuid(uuid);
|
state.setUuid(uuid);
|
||||||
state.setApiVersion(RuneLiteAPI.getVersion());
|
state.setApiVersion(RuneLiteAPI.getVersion());
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import java.io.FileWriter;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.UUID;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -59,7 +60,6 @@ public class SessionManager
|
|||||||
private final EventBus eventBus;
|
private final EventBus eventBus;
|
||||||
private final ConfigManager configManager;
|
private final ConfigManager configManager;
|
||||||
private final WSClient wsClient;
|
private final WSClient wsClient;
|
||||||
private final AccountClient loginClient = new AccountClient();
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private SessionManager(ConfigManager configManager, EventBus eventBus, WSClient wsClient)
|
private SessionManager(ConfigManager configManager, EventBus eventBus, WSClient wsClient)
|
||||||
@@ -184,6 +184,10 @@ public class SessionManager
|
|||||||
|
|
||||||
public void login()
|
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;
|
final OAuthResponse login;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -25,13 +25,13 @@
|
|||||||
package net.runelite.client.ws;
|
package net.runelite.client.ws;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import java.time.Duration;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.client.eventbus.EventBus;
|
import net.runelite.client.eventbus.EventBus;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
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 final Collection<Class<? extends WebsocketMessage>> messages = new HashSet<>();
|
||||||
|
|
||||||
private volatile Gson gson;
|
private volatile Gson gson;
|
||||||
|
@Getter
|
||||||
private UUID sessionId;
|
private UUID sessionId;
|
||||||
private WebSocket webSocket;
|
private WebSocket webSocket;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user