game instances

This commit is contained in:
Tim Tersch 2022-02-14 08:53:01 +01:00
parent 2278d6ae6d
commit e1103cf78e
2 changed files with 11 additions and 2 deletions

View File

@ -13,4 +13,8 @@ public class Game {
user = new User(); user = new User();
} }
public void processMessage(String msg) {
System.out.println(msg);
}
} }

View File

@ -4,6 +4,8 @@
public class WordleServer extends Server { public class WordleServer extends Server {
public static final int DEFAULT_PORT = 1000; public static final int DEFAULT_PORT = 1000;
List<Game> games;
public static void main( String[] args ) { public static void main( String[] args ) {
new WordleServer(); new WordleServer();
@ -21,11 +23,13 @@ public class WordleServer extends Server {
super(pPort); super(pPort);
db = new DatabaseConnector("", 0, "wordle.db", "", ""); db = new DatabaseConnector("", 0, "wordle.db", "", "");
games = new List<>();
} }
@Override @Override
public void processNewConnection( String pClientIP, int pClientPort ) { public void processNewConnection( String pClientIP, int pClientPort ) {
System.out.println("New connection: " + pClientPort); games.append(new Game(this));
} }
@Override @Override
@ -35,7 +39,8 @@ public class WordleServer extends Server {
@Override @Override
public void processMessage( String pClientIP, int pClientPort, String pMessage ) { public void processMessage( String pClientIP, int pClientPort, String pMessage ) {
System.out.println("Message: " + pMessage); games.toFirst();
games.getContent().processMessage(pMessage);
} }
} }