Package br.com.visualmidia.core.server

Examples of br.com.visualmidia.core.server.Communicate


        SSLSocketFactory sslComunicationSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
        SSLSocket sslComunicationSocket;
        sslComunicationSocket = (SSLSocket) sslComunicationSocketFactory.createSocket(GDSystem.getServerIp(), 9998);

        Communicate communicate = new Communicate(sslComunicationSocket);
        communicate.receiveAndSend("200, Thank you bastard Photogroup");
        if (communicate.receive().equals("201")) {
          communicate.send("209, Troca de imagens");
          if (communicate.receive().equals("700")) {
            communicate.send("707, Apague a foto");
            communicate.send(id);
            if (communicate.receive().equals("708")) {
              sslComunicationSocket.close();
              personPhoto.fillPhotoFromPerson(id, true);
              createandsetMessageBoxPhoto("Foto excluida com sucesso");
              removeImageButton.setEnabled(false);
            }
View Full Code Here


    try {
      if(!GDSystem.isStandAloneMode()) {
        SSLSocketFactory sslComunicationSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
        SSLSocket sslComunicationSocket = (SSLSocket) sslComunicationSocketFactory.createSocket(GDSystem.getServerIp(), 9998);
       
        Communicate communicate = new Communicate(sslComunicationSocket);
       
        communicate.receiveAndSend("200, Thank you bastard Photogroup");
        if (communicate.receive().equals("201")) {
          communicate.send("209, Troca de imagens");
          if (communicate.receive().equals("700")) {
            communicate.send("701, me manda a imagem");
            communicate.send(personId);
            if (communicate.receive().equals("704")) {// imagem encontrada
              communicate.send("705, nao precisa me mandar imagem");
              sslComunicationSocket.close();
              return true;
            } else {// imagem n�o encontrada
              sslComunicationSocket.close();
              return false;
View Full Code Here

        this.socket = socket;
        initCommunication();
    }

    private void initCommunication() {
        Communicate communicate = new Communicate(socket);
       
        File directory = new File(Constants.PREVAYLER_SERVER_DATA_DIRETORY);
    File file = null;
    Long newID = 0l;
    String fileName = "";
   
    for (String fileStr : directory.list()) {
      if(fileStr.contains(".snapshot")){
        Long oldID = Long.parseLong(fileStr.split(".snapshot")[0]);
        if(oldID > newID) {
          newID = oldID;
          fileName = fileStr;
        }
      }
    }
    if(newID == 0l) {
      communicate.send("301");
    } else {
      String location = Constants.DATA_FILES_PATH;
      file = new File(Constants.PREVAYLER_SERVER_DATA_DIRETORY  + Constants.FILE_SEPARATOR + fileName);
     
      communicate.send("303, Vou te enviar um arquivo");
      communicate.sendObject(new FileDescriptor(location, fileName, file.length(), 0));
      communicate.sendFile(file);
    }
       
        try {
            socket.close();
        } catch (IOException e) {
View Full Code Here

  public void checkFillLogo(final String logoName, final boolean isGetDefaultImage) {
    try {
        SSLSocketFactory sslComunicationSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
        SSLSocket sslComunicationSocket = (SSLSocket) sslComunicationSocketFactory.createSocket(GDSystem.getServerIp(), 9998);
 
        Communicate communicate = new Communicate(sslComunicationSocket);
       
        communicate.receiveAndSend("200, Thank you bastard");
        if (communicate.receive().equals("201")) {
          communicate.send("209, Troca de imagens");
          if (communicate.receive().equals("700")) {
            communicate.send("701, me manda a imagem");
            communicate.send(logoName);
            if (communicate.receive().equals("704")) {// imagem encontrada
              communicate.send("706, me mande a imagem");
              communicate.receiveLogo();
            } else {// imagem n�o encontrada
            }
          }
       
        sslComunicationSocket.close();
View Full Code Here

    private boolean logoExists(String logoName) {
    try {
        SSLSocketFactory sslComunicationSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
        SSLSocket sslComunicationSocket = (SSLSocket) sslComunicationSocketFactory.createSocket(GDSystem.getServerIp(), 9998);
       
        Communicate communicate = new Communicate(sslComunicationSocket);
       
        communicate.receiveAndSend("200, Thank you bastard");
        if (communicate.receive().equals("201")) {
          communicate.send("209, Troca de imagens");
          if (communicate.receive().equals("700")) {
            communicate.send("701, me manda a imagem");
            communicate.send(logoName);
            if (communicate.receive().equals("704")) {// imagem encontrada
              communicate.send("705, nao precisa me mandar imagem");
              sslComunicationSocket.close();
              return true;
            } else {// imagem n�o encontrada
              sslComunicationSocket.close();
              return false;
View Full Code Here

                    });

                    SSLSocketFactory sslComunicationSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
                    SSLSocket sslComunicationSocket = (SSLSocket) sslComunicationSocketFactory.createSocket(ServerAdress.getServerAdress(), 9998);

                    Communicate communicate = new Communicate(sslComunicationSocket);

                    communicate.receiveAndSend("200, Thank you bastard");
                    if(ServerAdress.getServerAdress().equals(GDSystem.getServerIp())){//� cliente da rede local
                      communicate.receiveAndSend("210, Send Me The Updates");
                    }else{
                      communicate.receiveAndSend("208, Send Me The Updates");
                    }

                    updateComposite.getDisplay().syncExec(new Runnable() {
                        public void run() {
                            primeriMessageLabel.setText("Procurando por atualiza��es...");
                        }
                    });
                   
                   
                    String receive = communicate.receive();
                    if (receive.equals("300")) {
                        if (communicate.sendAndReceive(Constants.BUILD_ID + ", Versao").equals("302")) {
                            communicate.send("306, Me mande informa��es da atualiza��o");

                            final List<Update> updateList = (List<Update>) communicate.receiveObject();

                            sslComunicationSocket.close();

                            updateComposite.getDisplay().syncExec(new Runnable() {
                                public void run() {
View Full Code Here

                        public void run() {
                            primeriMessageLabel.setText("Conectando");
                        }
                    });

                    Communicate communicate = new Communicate(sslComunicationSocket);
                   
                    communicate.addPropertyChangeListener(getMySelf());
                    communicate.receiveAndSend("200, Thank you bastard");
                    if(ServerAdress.getServerAdress().equals(GDSystem.getServerIp())){
                      communicate.receiveAndSend("210, Update me fucker");
                    }else{
                      communicate.receiveAndSend("208, Update me fucker");
                    }

                    updateComposite.getDisplay().syncExec(new Runnable() {
                        public void run() {
                            primeriMessageLabel.setText("Procurando por atualiza��es...");
                        }
                    });


//                    ArrayList<FileDescriptorMD5> listOfFilefromServer = null;
//                    communicate.send("315, Me mande a lista dos arquivos do server");
//                    if (communicate.receive().equals("316")){
//                      String path = communicate.receive();
//                      listOfFilefromServer = (ArrayList<FileDescriptorMD5>) communicate.receiveObject();
//                      communicate.send("317, Lista recebida");
//                    }else if ( communicate.receive().equals(("318"))){
//                      communicate.sendObject(new ListFilestoDownloadThroughCompareofMD5().getListofFilesThatHasDifferentMD5tobeDownloaded(listOfFilefromServer));
//                      while (communicate.receive().equals("319")) {
//                        final FileDescriptorMD5 fileDescriptorMD5 = (FileDescriptorMD5) communicate.receiveObject();
//                       
//                        updateComposite.getDisplay().syncExec(new Runnable() {
//                          public void run() {
//                            primeriMessageLabel.setText("Recebendo: " + fileDescriptorMD5.getName());
//                            primeriMessageLabel.setText("");
//                           
//                            fileBar.setMaximum(Integer.parseInt(String.valueOf(fileDescriptorMD5.getSize())));
//                            fileBar.setSelection(0);
//                          }
//                        });
//                       
//                        communicate.send("320, Envie o proximo");
//                       
//                        if (communicate.receiveFile(fileDescriptorMD5)) {
//                          communicate.send("321, Arquivo recebido com sucesso");
//                         
//                          updateComposite.getDisplay().syncExec(new Runnable() {
//                            public void run() {
//                              primeriMessageLabel.setText("Arquivo recebido com sucesso");
//                            }
//                          });
//                        } else {
//                          communicate.send("322, Problema ao Receber o arquivo");
//                         
//                          updateComposite.getDisplay().syncExec(new Runnable() {
//                            public void run() {
//                              primeriMessageLabel.setText("Problema na recep��o do arquivo");
//                            }
//                          });
//                        }
//                      }
//                    }
                   
                   
                    String receive = communicate.receive();
                    if (receive.equals("300")) {
                        if (communicate.sendAndReceive(Constants.BUILD_ID + ", Versao").equals("302")) {

                            updateComposite.getDisplay().syncExec(new Runnable() {
                                public void run() {
                                    primeriMessageLabel.setText("Progresso Geral:");
                                }
                            });
                           
                            communicate.send("305, Me mande os arquivos");
                            if(ServerAdress.getServerAdress().equals(GDSystem.getServerIp()) || communicate.receive().equals("311")) {
                               if(!ServerAdress.getServerAdress().equals(GDSystem.getServerIp()))
                                 communicate.sendObject(new Autentication((String) gd.get("username"), (String) gd.get("password"), (String) gd.get("serialnumber")));
                              
                                if(ServerAdress.getServerAdress().equals(GDSystem.getServerIp()) || communicate.receive().equals("312")) {
                                    while (communicate.receive().equals("303")) {
                                        final FileDescriptor fileDescriptor = (FileDescriptor) communicate.receiveObject();
       
                                        updateComposite.getDisplay().syncExec(new Runnable() {
                                            public void run() {
                                                secondMessageLabel.setText("Recebendo: " + fileDescriptor.getName());
                                                downloadStatus.setText("");
       
                                                fileBar.setMaximum(Integer.parseInt(String.valueOf(fileDescriptor.getSize())));
                                                fileBar.setSelection(0);
                                            }
                                        });
                                       
                                        communicate.send("309");
       
                                        if (communicate.receiveFile(fileDescriptor)) {
                                            communicate.send("307");
                                           
                                            updateComposite.getDisplay().syncExec(new Runnable() {
                                                public void run() {
                                                    secondMessageLabel.setText("Arquivo recebido com sucesso");
                                                }
                                            });
                                        } else {
                                            communicate.send("308");
                                           
                                            updateComposite.getDisplay().syncExec(new Runnable() {
                                                public void run() {
                                                    secondMessageLabel.setText("Problema na recep��o do arquivo");
                                                }
View Full Code Here

  private void checkUpdates() {
        try {
            SSLSocketFactory sslComunicationSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
            SSLSocket sslComunicationSocket = (SSLSocket) sslComunicationSocketFactory.createSocket(ServerAdress.getServerAdress(), 9998);

            Communicate communicate = new Communicate(sslComunicationSocket);
            communicate.receiveAndSend("200, Thank you bastard");
            communicate.receiveAndSend("208, Send Me The Updates");
           
            String receive = communicate.receive();
            if(receive.equals("300")) {
                if(communicate.sendAndReceive(Constants.BUILD_ID + ", Versao").equals("302")) {
                    communicate.send("306, Me mande informa��es da atualiza��o");
                   
                    updateList = (List<Update>) communicate.receiveObject();
                   
                    sslComunicationSocket.close();
                }
            }
        } catch (Exception exception) {
View Full Code Here

        this.socket = socket;
        initCommunication();
    }

  private void initCommunication() {
        Communicate communicate = new Communicate(socket);
       
        String buildId = communicate.sendAndReceive("300, Qual sua vers�o?");
       
        List<Update> updateToBeMadeInTheCliente = getUpdateList(buildId);
        if(updateToBeMadeInTheCliente.size() > 0) {
            String response = communicate.sendAndReceive("302, Voc� precisa de atualiza��o");
            if(response.equals("305")) {
                for (Update update : updateToBeMadeInTheCliente) {
                    List<File> files = update.getFiles();
                    for (int i = 0; i < files.size(); i++) {
                        File file = files.get(i);
                        if(socket.isClosed()) {
                            return;
                        }
                        String fileRemotePath = getPath(update.getBuildId(), file.getPath(), file.getName());
                               
                        communicate.send("303, Vou te enviar um arquivo");
                        communicate.sendObject(new FileDescriptor(fileRemotePath, file.getName(), file.length(), Long.parseLong(update.getBuildId())));
                       
                        if(communicate.receive().equals("309")) {
                          communicate.sendFile(file);
                            if(communicate.receive().equals("308")){
                                i--;
                            }
                        }
                    }
                }
                communicate.send("304");
            } else if(response.equals("306")) {
                communicate.sendObject(updateToBeMadeInTheCliente);
            }
        } else {
            communicate.send("301, Voc� est� atualizado!");
        }
       
        try {
            socket.close();
        } catch (IOException e) {
View Full Code Here

        SSLSocketFactory sslComunicationSocketFactory = (SSLSocketFactory) SSLSocketFactory
        .getDefault();
        SSLSocket sslComunicationSocket = (SSLSocket) sslComunicationSocketFactory
        .createSocket(GDSystem.getServerIp(), 9998);

        Communicate communicate = new Communicate(sslComunicationSocket);

        communicate.receiveAndSend("200, Thank you bastard");
        if (communicate.receive().equals("201")) {
          communicate.send("209, Troca de imagens");
          if (communicate.receive().equals("700")) {
            communicate.send("701, me manda a imagem");
            communicate.send(personId);
            if (communicate.receive().equals("704")) {// imagem
              // encontrada
              communicate
              .send("705, nao precisa me mandar imagem");
              sslComunicationSocket.close();
              return true;
            } else {// imagem n�o encontrada
              sslComunicationSocket.close();
View Full Code Here

TOP

Related Classes of br.com.visualmidia.core.server.Communicate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.