Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void printMenu(){
- System.out.println("Welcome to dropMusic");
- System.out.println("1- Login");
- System.out.println("2- Sign up");
- }
- private static String menu() {
- int opt;
- String msg="";
- Scanner scan = new Scanner(System.in);
- opt = scan.nextInt();
- switch (opt) {
- case 1:
- scan.nextLine();
- String user, pass;
- System.out.println("Username: ");
- user = scan.nextLine();
- System.out.println("Password: ");
- pass = scan.nextLine();
- msg = "type / login ; username / " + user + "; password / " + pass;
- break;
- case 2:
- String name,mail;
- scan.nextLine();
- System.out.println("Nome: ");
- name = scan.nextLine();
- System.out.println("Username: ");
- user = scan.nextLine();
- System.out.println("Password: ");
- pass = scan.nextLine();
- System.out.println("Email: ");
- mail = scan.nextLine();
- msg = "type / sign up ; item_count / 3 ; name / " + name +" ; username / "+user+ " ; password / " + pass+" ; mail / "+mail;
- System.out.println(msg);
- break;
- }
- return msg;
- }
- public static void main(String[] args)
- throws MalformedURLException, RemoteException, NotBoundException, IOException {
- String line = "";
- line="";
- System.getProperties().put("java.security.policy", "out/production/projeto2/policy.all");
- System.setSecurityManager(new RMISecurityManager());
- ServerRmiInt si = null;
- ClientRmi c = new ClientRmi();
- c.setNome(args[0]);
- si = (ServerRmiInt) Naming.lookup(nomeServer);
- si.subscribe(args[0], c);
- System.out.println("Request sent to Server");
- InputStreamReader input = new InputStreamReader(System.in);
- BufferedReader reader = new BufferedReader(input);
- printMenu();
- // entra em ciclo para comunnicacao com o server rmi
- while (true) {
- try {
- line = menu();
- si.sendMulti(line, args[0], c);
- if (line.equals("type / share")) {// comando share para partilhar up/download
- uploadDownloadTCP();
- }
- } catch (java.rmi.ConnectException e) {// trata da falha no servidor principal para passar ao backup
- si = (ServerRmiInt) Naming.lookup(nomeServer);
- si.subscribe(args[0], c);
- System.out.println("aqui");
- si.sendMulti(line, args[0], c);
- } catch (RemoteException re) {
- System.out.println("Exception remote in main " + re);
- } catch (IOException e) {
- System.out.println("Exception in main " + e);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement