add: cli ui connection with server

This commit is contained in:
ramollia
2025-09-17 17:25:54 +02:00
parent 49b9d5a87c
commit a502034685
2 changed files with 44 additions and 38 deletions

View File

@@ -20,41 +20,9 @@ public class Main {
private static final Logger logger = LogManager.getLogger(Main.class);
public static void main(String[] args) throws ExecutionException, InterruptedException {
initSystems();
CompletableFuture<String> serverIdFuture = new CompletableFuture<>();
GlobalEventBus.post(new Events.ServerEvents.StartServerRequest("5001", "tictactoe", serverIdFuture));
String serverId = serverIdFuture.get();
CompletableFuture<String> connectionIdFuture = new CompletableFuture<>();
GlobalEventBus.post(new Events.ServerEvents.StartConnectionRequest("127.0.0.1", "5001", connectionIdFuture));
String connectionId = connectionIdFuture.get();
CompletableFuture<String> ticTacToeGame = new CompletableFuture<>();
GlobalEventBus.post(new Events.ServerEvents.CreateTicTacToeGameRequest(serverId, "J", "P", ticTacToeGame));
String ticTacToeGameId = ticTacToeGame.get();
GlobalEventBus.post(new Events.ServerEvents.RunTicTacToeGame(serverId, ticTacToeGameId));
GlobalEventBus.post(new Events.ServerEvents.SendCommand(
connectionId,
"gameid " + ticTacToeGameId, "player J", "MOVE", "0"
));
GlobalEventBus.post(new Events.ServerEvents.SendCommand(
connectionId,
"gameid " + ticTacToeGameId, "player P", "MOVE", "1"
));
// for (int x = 0; x < 20000000; x++) {
// CompletableFuture<String> ticTacToeGame = new CompletableFuture<>();
// GlobalEventBus.post(new Events.ServerEvents.CreateTicTacToeGameRequest(serverId, "J"+x, "P"+x, ticTacToeGame));
// String ticTacToeGameId = ticTacToeGame.get();
// GlobalEventBus.post(new Events.ServerEvents.RunTicTacToeGame(serverId, ticTacToeGameId));
// GlobalEventBus.post(new Events.ServerEvents.Command(connectionId, "MOVE", "" + x));
// }
ConsoleGui console = new ConsoleGui();
GameBase.State state = GameBase.State.INVALID;
do {
console.print();