
/**
 * Server für das WORDLE Spiel.
 */
public class WordleServer extends Server {

    public static final int DEFAULT_PORT = 1000;

    public static void main( String[] args ) {
        new WordleServer();
    }


    private DatabaseConnector db;

    private List<User> userList;
    private Query query;


    public WordleServer() {
        this(DEFAULT_PORT);
    }

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

}
