diff --git a/User.java b/User.java index fcd21fe..17e912e 100644 --- a/User.java +++ b/User.java @@ -1,5 +1,5 @@ public class User { - int connectionID; + String connectionID; String username; String password; int timesPlayed; @@ -11,7 +11,7 @@ public class User { int [] wonInTurn; Game game; - public User (int pConnectionID){ + public User (String pConnectionID){ connectionID =pConnectionID; game = new Game(); } @@ -20,7 +20,7 @@ public class User { return game; } - public int getConnectionID() { + public String getConnectionID() { return connectionID; } @@ -60,7 +60,7 @@ public class User { return username; } - public void setConnectionID(int connectionID) { + public void setConnectionID(String connectionID) { this.connectionID = connectionID; } diff --git a/WordleServer.java b/WordleServer.java index e2ab8c5..1d44b67 100644 --- a/WordleServer.java +++ b/WordleServer.java @@ -13,6 +13,9 @@ public class WordleServer extends Server { private DatabaseConnector db; + private List userList; + private Query query; + public WordleServer() { this(DEFAULT_PORT); @@ -20,23 +23,33 @@ public class WordleServer extends Server { public WordleServer( int pPort ) { super(pPort); - + query = new Query(); db = new DatabaseConnector("", 0, "wordle.db", "", ""); + userList = new List(); } @Override public void processNewConnection( String pClientIP, int pClientPort ) { + String connectionID= pClientIP +":"+ Integer.toString(pClientPort); + User u = new User(connectionID); + userList.append(u); + send(pClientIP,pClientPort,"+OK Verbindung zum Wordle Server erfolgreich aufgebaut"); } @Override public void processClosingConnection( String pClientIP, int pClientPort ) { + } @Override public void processMessage( String pClientIP, int pClientPort, String pMessage ) { - + if(pMessage.equals("QUIT")){ + send(pClientIP,pClientPort,"+OK Bye"); + } else { + send(pClientIP,pClientPort,"-ERR Command not valid in this state"); + } } }