@Override
    public void run() {
        while((client.isConnected()) && !client.isLogged()) {
            client.println(welcomeMessage);
            String nick = client.readLine();
            if ((nick != null) && (!farewellMessage.equals(nick))) {
                if (client.setNick(nick)) {
                    queueOfMessages.addLast(client.getNick() + " connected");
                }
            } else {
                closeConnection();
            }
        }
        while(client.isConnected() && client.isLogged()) {
            String s = client.readLine();
            if ((s != null) && (!farewellMessage.equals(s))) {
                queueOfMessages.addLast(client.getNick() + ">>" + s);
            } else {
                closeConnection();
            }
        }
    }