summaryrefslogtreecommitdiff
path: root/core/src/kz/ilotterytea/maxon/session/IdentityClient.java
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-01-05 00:14:45 +0500
committerilotterytea <iltsu@alright.party>2025-01-05 00:58:57 +0500
commitb0f71c097631f6f9d595865c48f1ffd1990e8794 (patch)
tree0c2a12ba73a9610c6d7aaaf912b08c39f221a4c7 /core/src/kz/ilotterytea/maxon/session/IdentityClient.java
parent47303cced8f6e55aaab2579293da49723ba39c1d (diff)
feat: established communication between game and serverHEADmaster
Diffstat (limited to 'core/src/kz/ilotterytea/maxon/session/IdentityClient.java')
-rw-r--r--core/src/kz/ilotterytea/maxon/session/IdentityClient.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/src/kz/ilotterytea/maxon/session/IdentityClient.java b/core/src/kz/ilotterytea/maxon/session/IdentityClient.java
index 570b16b..831589d 100644
--- a/core/src/kz/ilotterytea/maxon/session/IdentityClient.java
+++ b/core/src/kz/ilotterytea/maxon/session/IdentityClient.java
@@ -10,6 +10,7 @@ import com.badlogic.gdx.utils.JsonValue;
import com.badlogic.gdx.utils.JsonWriter;
import com.badlogic.gdx.utils.Timer;
import kz.ilotterytea.maxon.MaxonConstants;
+import kz.ilotterytea.maxon.MaxonGame;
import kz.ilotterytea.maxon.utils.RandomUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -90,6 +91,8 @@ public class IdentityClient {
IdentityClient.this.userId = String.valueOf(json.get("data").get("user").getInt("id"));
IdentityClient.this.isAuthorised = true;
log.info("Successfully authorised! Welcome back, {}!", IdentityClient.this.username);
+
+ MaxonGame.getInstance().getSessionClient().connect();
} catch (Exception e) {
log.error("An exception was thrown while authorising", e);
}
@@ -141,6 +144,7 @@ public class IdentityClient {
accessToken = null;
userId = null;
isAuthorised = false;
+ MaxonGame.getInstance().getSessionClient().close(5001, "Failed to validate token");
authorize(username, password);
return;
}
@@ -213,6 +217,8 @@ public class IdentityClient {
sessionPreferences.remove("username");
sessionPreferences.remove("password");
sessionPreferences.flush();
+
+ MaxonGame.getInstance().getSessionClient().close(5001, "Invalidated token");
} catch (Exception ignored) {
}
}
@@ -262,11 +268,14 @@ public class IdentityClient {
userId = null;
isAuthorised = false;
log.warn(error);
+ MaxonGame.getInstance().getSessionClient().close(5002, "Failed to refresh token");
return;
}
accessToken = json.get("data").get("accessToken").asString();
log.info("Token has been refreshed!");
+
+ MaxonGame.getInstance().getSessionClient().updateIdentity();
} catch (Exception e) {
log.error("An exception was thrown while refreshing", e);
}