public static void main(String[] args) {
        try{
            int i = 0; // счетчик подключений
            ServerSocket server = new ServerSocket(SERVER_PORT);// слушаем порт 1234
            Socket socket;
            while(true) {

                socket = server.accept();
                if (getNumberOfUsers() < MAX_NUMBER_OF_USERS) {
                    String name;

                    System.out.println("Trying to connect");
                    (new BufferedReader(new InputStreamReader(socket.getInputStream()))).readLine();
                    while (true) {
                        name = (new BufferedReader(new InputStreamReader(socket.getInputStream()))).readLine();
                        if (!checkUserNamePassword(name)){
                            say(socket,"Wrong password, try again.");
                            say(socket,"Enter your name:");
                            continue;
                        }else {
                            name = name.substring(0,name.indexOf(":"));
                        }
                        if (checkName(name)) {
                            say(socket, "OK");
                            break;
                        } else {
                            say(socket, "This name is already taken. Try another:");
                        }
                    }
                    i++;
                    new Server(getNewUser(name, socket), socket, name);
                    if (messageKeeper.getMessages() != null) {
                        say(socket, "------------------");
                        say(socket, "Previous comments:");
                        for (String s : messageKeeper.getMessages()) {
                            say(socket, s);
                        }
                        say(socket, "------------------");
                    }
                    System.out.println("New client: number " + i + ", Name: " + name);
                }else {
                    new CancelServer(socket);
                }
            }

        } catch(Exception e){
            e.printStackTrace();
        }
    }