private void registerName() {
        while (registeredUsername == null && storageServices.isRunning()) {
            String userName = storageServices.popUserName();    // blokierender Aufruf der auf den UserNamen wartet.
            println(new_(userName));    // send to the server
            System.out.println("Sent: " + userName);
            List<String> tokens;
            try {
                tokens = readFromServer();
                System.out.println("Recv: " + tokens);
                if (isSucess(tokens)) {  // if the registration succeeded
                    registeredUsername = userName;  // save the username. this will also end the loop.
                    guiServices.nameRegistrationResponse(OK);       // tell the gui, that it was successful.
                } else {
                    guiServices.nameRegistrationResponse(tokens.get(1));    // tell the gui that it failed and start from beginning of loop
                }
            } catch (IOException e) {
                System.err.println(e.getMessage());
                storageServices.stop();
            }
        }
    }