Renamed command to SendCommand

This commit is contained in:
lieght
2025-09-17 16:02:02 +02:00
parent 4671885ad7
commit 620e98d29e
9 changed files with 131 additions and 6 deletions

View File

@@ -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"
));

View File

@@ -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.

View File

@@ -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());