src/com/company/Server/CentralNodeInstructions.java
public synchronized void sendToAll(Client client, SynchronizedArrayList<WorkerThread> clientsConnected) {

        if (Pattern.matches("^[0-9]{9}(;[0-9]{9})*$", client.getListContact())) {
            String[] listContact = client.getListContact().split(";");
            int idConvInt = Integer.parseInt(listContact[0]);
            boolean found = false;

            for (int i = 0; !found && i < clientsConnected.get().size(); i++) {
                if (idConvInt == clientsConnected.get().get(i).client.getId()) {
                    found = true;
                    clientsConnected.get().get(i).out.println("All contacts have been successfully alerted!");
                }
            }

            for (int i = 1; i < listContact.length; i++) {
                found = false;
                idConvInt = Integer.parseInt(listContact[i]);
                //System.out.println("ID CONTACT: " + idConvInt);

                for (int j = 0; !found && j < clientsConnected.get().size(); j++) {
                    // If the user is online
                    if (idConvInt == clientsConnected.get().get(j).client.getId()) {
                        found = true;
                        clientsConnected.get().get(i).out.println("You have been in contact with an infected person. " +
                                "It is necessary to take the covid-19 test!");
                    }
                }
                // If the user is offline
                if (!found) {
                    // If the user is registered in the application
                    if (this.readWriteFiles.userExists(idConvInt)) {
                        this.readWriteFiles.updateNotificationContactUser(idConvInt);
                    } else {
                        this.readWriteFiles.writeUnregisteredUsers(idConvInt);
                    }
                }
            }
        } else {
            String[] listContact = client.getListContact().split(";");
            int idConvInt = Integer.parseInt(listContact[0]);
            boolean found = false;

            for (int i = 0; !found && i < clientsConnected.get().size(); i++) {
                if (idConvInt == clientsConnected.get().get(i).client.getId()) {
                    found = true;
                    clientsConnected.get().get(i).out.println("Invalid nearby contacts entry");
                }
            }
        }
    }
/**
     * Method responsible for sending to the client, who added the nearby contacts, the following message: "All contacts have been
     * successfully alerted!" and is also responsible for sending to the nearby contacts ,that have been added, the following message:
     * "You have been in contact with an infected person! It is necessary to take the test!"
     *
     * @param client           client object (model)
     * @param clientsConnected array of clients currently connected to the application
     */
Method responsible for sending to the client, who added the nearby contacts, the following message: "All contacts have been
successfully alerted!" and is also responsible for sending to the nearby contacts ,that have been added, the following message:
"You have been in contact with an infected person. It is necessary to take the test!"

@param client           client object (model)
@param clientsConnected array of clients currently connected to the application
Method responsible for sending to the client who added the nearby contacts the following message : " All contacts have been successfully alerted! " and is also responsible for sending to the nearby contacts that have been added the following message : " You have been in contact with an infected person . It is necessary to take the test! " @param client client object ( model ) @param clientsConnected array of clients currently connected to the application
public synchronized void sendToAll(Client client, SynchronizedArrayList<WorkerThread> clientsConnected) {
        if (Pattern.matches("^[0-9]{9}(;[0-9]{9})*$", client.getListContact())) {
            String[] listContact = client.getListContact().split(";");
            int idConvInt = Integer.parseInt(listContact[0]);
            boolean found = false;
            for (int i = 0; !found && i < clientsConnected.get().size(); i++) {
                if (idConvInt == clientsConnected.get().get(i).client.getId()) {
                    found = true;
                    clientsConnected.get().get(i).out.println("All contacts have been successfully alerted!");
                }
            }
            for (int i = 1; i < listContact.length; i++) {
                found = false;
                idConvInt = Integer.parseInt(listContact[i]);
                for (int j = 0; !found && j < clientsConnected.get().size(); j++) {
                    if (idConvInt == clientsConnected.get().get(j).client.getId()) {
                        found = true;
                        clientsConnected.get().get(i).out.println("You have been in contact with an infected person. " +
                                "It is necessary to take the covid-19 test!");
                    }
                }
                if (!found) {
                    if (this.readWriteFiles.userExists(idConvInt)) {
                        this.readWriteFiles.updateNotificationContactUser(idConvInt);
                    } else {
                        this.readWriteFiles.writeUnregisteredUsers(idConvInt);
                    }
                }
            }
        } else {
            String[] listContact = client.getListContact().split(";");
            int idConvInt = Integer.parseInt(listContact[0]);
            boolean found = false;
            for (int i = 0; !found && i < clientsConnected.get().size(); i++) {
                if (idConvInt == clientsConnected.get().get(i).client.getId()) {
                    found = true;
                    clientsConnected.get().get(i).out.println("Invalid nearby contacts entry");
                }
            }
        }
    }
public synchronized void sendToAll ( Client client , SynchronizedArrayList < WorkerThread > clientsConnected ) { if ( Pattern . matches ( "^[0-9]{9}(;[0-9]{9})*$" , client . getListContact ( ) ) ) { String [ ] listContact = client . getListContact ( ) . split ( ";" ) ; int idConvInt = Integer . parseInt ( listContact [ 0 ] ) ; boolean found = false ; for ( int i = 0 ; ! found && i < clientsConnected . get ( ) . size ( ) ; i ++ ) { if ( idConvInt == clientsConnected . get ( ) . get ( i ) . client . getId ( ) ) { found = true ; clientsConnected . get ( ) . get ( i ) . out . println ( "All contacts have been successfully alerted!" ) ; } } for ( int i = 1 ; i < listContact . length ; i ++ ) { found = false ; idConvInt = Integer . parseInt ( listContact [ i ] ) ; for ( int j = 0 ; ! found && j < clientsConnected . get ( ) . size ( ) ; j ++ ) { if ( idConvInt == clientsConnected . get ( ) . get ( j ) . client . getId ( ) ) { found = true ; clientsConnected . get ( ) . get ( i ) . out . println ( "You have been in contact with an infected person. " + "It is necessary to take the covid-19 test!" ) ; } } if ( ! found ) { if ( this . readWriteFiles . userExists ( idConvInt ) ) { this . readWriteFiles . updateNotificationContactUser ( idConvInt ) ; } else { this . readWriteFiles . writeUnregisteredUsers ( idConvInt ) ; } } } } else { String [ ] listContact = client . getListContact ( ) . split ( ";" ) ; int idConvInt = Integer . parseInt ( listContact [ 0 ] ) ; boolean found = false ; for ( int i = 0 ; ! found && i < clientsConnected . get ( ) . size ( ) ; i ++ ) { if ( idConvInt == clientsConnected . get ( ) . get ( i ) . client . getId ( ) ) { found = true ; clientsConnected . get ( ) . get ( i ) . out . println ( "Invalid nearby contacts entry" ) ; } } } }
Method responsible for sending to the client, who added the nearby contacts, the following message: "All contacts have been
 successfully alerted!"
Method responsible for sending to the client who added the nearby contacts the following message : " All contacts have been successfully alerted! "
//System.out.println("ID CONTACT: " + idConvInt); // If the user is online // If the user is offline // If the user is registered in the application