From 620e98d29e33b2ba9f39bb41d7d98679afae1532 Mon Sep 17 00:00:00 2001 From: lieght Date: Wed, 17 Sep 2025 16:02:02 +0200 Subject: [PATCH] Renamed command to SendCommand --- .idea/compiler.xml | 13 ++++ .idea/encodings.xml | 7 ++ .idea/jarRepositories.xml | 20 ++++++ .idea/misc.xml | 12 ++++ .idea/vcs.xml | 6 ++ .idea/workspace.xml | 69 ++++++++++++++++++- src/main/java/org/toop/Main.java | 4 +- src/main/java/org/toop/eventbus/Events.java | 2 +- .../server/frontend/ConnectionManager.java | 4 +- 9 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..3deac64 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..54267fb --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5f83e1c..17e4b1a 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,8 +1,75 @@ + + + + + + + + + + + + + + + + - {} + + + + + + + + + + + 1758117514311 + + + + + \ No newline at end of file diff --git a/src/main/java/org/toop/Main.java b/src/main/java/org/toop/Main.java index 09623ba..5ba1913 100644 --- a/src/main/java/org/toop/Main.java +++ b/src/main/java/org/toop/Main.java @@ -36,11 +36,11 @@ public class Main { String ticTacToeGameId = ticTacToeGame.get(); GlobalEventBus.post(new Events.ServerEvents.RunTicTacToeGame(serverId, ticTacToeGameId)); - GlobalEventBus.post(new Events.ServerEvents.Command( + GlobalEventBus.post(new Events.ServerEvents.SendCommand( connectionId, "gameid " + ticTacToeGameId, "player J", "MOVE", "0" )); - GlobalEventBus.post(new Events.ServerEvents.Command( + GlobalEventBus.post(new Events.ServerEvents.SendCommand( connectionId, "gameid " + ticTacToeGameId, "player P", "MOVE", "1" )); diff --git a/src/main/java/org/toop/eventbus/Events.java b/src/main/java/org/toop/eventbus/Events.java index 60d95bc..a0a3667 100644 --- a/src/main/java/org/toop/eventbus/Events.java +++ b/src/main/java/org/toop/eventbus/Events.java @@ -129,7 +129,7 @@ public class Events implements IEvents { /** * Triggers sending a command to a server. */ - public record Command(String connectionId, String... args) { } + public record SendCommand(String connectionId, String... args) { } /** * Triggers when a command is sent to a server. diff --git a/src/main/java/org/toop/server/frontend/ConnectionManager.java b/src/main/java/org/toop/server/frontend/ConnectionManager.java index cab82e6..ad76ceb 100644 --- a/src/main/java/org/toop/server/frontend/ConnectionManager.java +++ b/src/main/java/org/toop/server/frontend/ConnectionManager.java @@ -27,7 +27,7 @@ public class ConnectionManager { public ConnectionManager() { GlobalEventBus.subscribeAndRegister(Events.ServerEvents.StartConnectionRequest.class, this::handleStartConnectionRequest); GlobalEventBus.subscribeAndRegister(Events.ServerEvents.StartConnection.class, this::handleStartConnection); - GlobalEventBus.subscribeAndRegister(Events.ServerEvents.Command.class, this::handleCommand); + GlobalEventBus.subscribeAndRegister(Events.ServerEvents.SendCommand.class, this::handleCommand); GlobalEventBus.subscribeAndRegister(Events.ServerEvents.Reconnect.class, this::handleReconnect); GlobalEventBus.subscribeAndRegister(Events.ServerEvents.ChangeConnection.class, this::handleChangeConnection); GlobalEventBus.subscribeAndRegister(Events.ServerEvents.ForceCloseAllConnections.class, _ -> shutdownAll()); @@ -55,7 +55,7 @@ public class ConnectionManager { )); } - private void handleCommand(Events.ServerEvents.Command event) { // TODO: Move this to ServerConnection class, keep it internal. + private void handleCommand(Events.ServerEvents.SendCommand event) { // TODO: Move this to ServerConnection class, keep it internal. ServerConnection serverConnection = this.serverConnections.get(event.connectionId()); if (serverConnection != null) { serverConnection.sendCommandByString(event.args());