forked from IF-LK-2020/wordle
not Valid Command und Willkommens und schlussnachricht hinzugefügt
This commit is contained in:
parent
59f55d3249
commit
29bfa66d09
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@ public class WordleServer extends Server {
|
|||
|
||||
private DatabaseConnector db;
|
||||
|
||||
private List<User> 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<User>();
|
||||
}
|
||||
|
||||
@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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue