summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-01-23 20:31:23 +0500
committerilotterytea <iltsu@alright.party>2025-01-23 20:31:23 +0500
commitff9d8f584616cc3d9d7000e95f681707fd508497 (patch)
treeb56f83b921f887424e69fffde8c34753a4e09baa /core/src
parentc94a51d6ab4863e2fa6fd230def08aac3f2bf73a (diff)
feat: server-side sign-in implementation
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/java/kz/ilotterytea/frogartha/sessions/SessionClient.java16
-rw-r--r--core/src/main/java/kz/ilotterytea/frogartha/sessions/SessionHandlers.java6
2 files changed, 14 insertions, 8 deletions
diff --git a/core/src/main/java/kz/ilotterytea/frogartha/sessions/SessionClient.java b/core/src/main/java/kz/ilotterytea/frogartha/sessions/SessionClient.java
index a696121..681b377 100644
--- a/core/src/main/java/kz/ilotterytea/frogartha/sessions/SessionClient.java
+++ b/core/src/main/java/kz/ilotterytea/frogartha/sessions/SessionClient.java
@@ -10,6 +10,7 @@ import kz.ilotterytea.frogartha.FrogarthaGame;
import kz.ilotterytea.frogartha.domain.Identity;
import kz.ilotterytea.frogartha.domain.PlayerData;
import kz.ilotterytea.frogartha.domain.RoomTopic;
+import kz.ilotterytea.frogartha.domain.actions.IdentificationAction;
import kz.ilotterytea.frogartha.domain.actions.JoinRoomAction;
import kz.ilotterytea.frogartha.domain.actions.LeaveRoomAction;
import kz.ilotterytea.frogartha.domain.events.*;
@@ -29,6 +30,7 @@ public class SessionClient implements WebSocketListener {
private boolean isJoining, joined;
private Integer connectionId;
+ private Identity identity;
private RoomTopic topic;
private Throwable lastThrow;
@@ -75,7 +77,10 @@ public class SessionClient implements WebSocketListener {
}
if (obj instanceof IdentifiedEvent) {
- SessionHandlers.handleIdentifiedEvent((IdentifiedEvent) obj);
+ IdentifiedEvent x = (IdentifiedEvent) obj;
+ identity = x.getIdentity();
+ connectionId = x.getPlayerId();
+ log.log("The server identified me! I'm {} with ID {}", identity, connectionId);
} else if (obj instanceof PlayerJumpEvent) {
SessionHandlers.handlePlayerJumpEvent((PlayerJumpEvent) obj);
} else if (obj instanceof ChangedDirectionEvent) {
@@ -145,7 +150,10 @@ public class SessionClient implements WebSocketListener {
}
public void updateIdentity() {
- send(new Identity(game.getIdentityClient().getUsername()));
+ send(new IdentificationAction(
+ game.getIdentityClient().getClientToken(),
+ game.getIdentityClient().getAccessToken()
+ ));
}
public int getConnectionId() {
@@ -156,6 +164,10 @@ public class SessionClient implements WebSocketListener {
this.connectionId = connectionId;
}
+ public Identity getIdentity() {
+ return identity;
+ }
+
public Throwable getLastThrow() {
Throwable cpy = lastThrow;
this.lastThrow = null;
diff --git a/core/src/main/java/kz/ilotterytea/frogartha/sessions/SessionHandlers.java b/core/src/main/java/kz/ilotterytea/frogartha/sessions/SessionHandlers.java
index 9ced32b..0c89b04 100644
--- a/core/src/main/java/kz/ilotterytea/frogartha/sessions/SessionHandlers.java
+++ b/core/src/main/java/kz/ilotterytea/frogartha/sessions/SessionHandlers.java
@@ -16,12 +16,6 @@ public class SessionHandlers {
private static final FrogarthaGame game = FrogarthaGame.getInstance();
private static final SessionClient client = game.getSessionClient();
- public static void handleIdentifiedEvent(IdentifiedEvent event) {
- log.log("The server identified me!");
-
- client.setConnectionId(event.getPlayerId());
- }
-
public static void handlePlayerJumpEvent(PlayerJumpEvent event) {
if (!game.getScreen().getClass().equals(GameScreen.class)) {
log.log("The screen is not GameScreen, but the session received PlayerJumpEvent");