@Override
    public void run() {
        while(true) {
            
            try {
                Socket socket = server.accept();
                BufferedReader inFromClient =
               new BufferedReader(new InputStreamReader(socket.getInputStream()));
                        
                        
                StringBuilder builder = new StringBuilder();
                String aux = "";

                while ((aux = inFromClient.readLine()) != null) {
                    builder.append(aux);
                }
                String text = builder.toString();
                NetworkMessage message = NetworkMessage.parse(text);
                message.setSender(socket.getInetAddress());
                message.setReceiver(Network.getLocalAddress());
                
                //System.out.println("DOWNLOAD");
                switch (message.type){
                    case NetworkMessage.TYPE_FILE:
                        
                        System.out.println("DOWNLOADING IN");
                        String[] s = message.content.split(",");
                        inFromClient.close();
                        //server.close();
                          socket = server.accept();
                        message.content=download( s[0], socket);
                        message.setType(8);
                        break;
                    default:
                        break;
                }
                        
                
                
                
                //Evento
                setChanged();
                notifyObservers(message);
                
            }
            catch(Exception e) {
                System.err.println("Connection error receiving message \n"+e.getMessage());
            }
        }
    }