|
Erstellt von David Utza
vor fast 8 Jahre
|
|
import java.io.*;import java.rmi.*;/** * Klasse EchoClient * * @version 2016-09-09 * @author David */public class EchoClient { public static final String EXIT = "exit"; public static final String PROMPT_CLIENT = "EchoClient> "; public static final String PROMPT_SERVER = "EchoServer> "; public static int uid; public static void main(String[] args) { EchoService es = null; String request = null; String response = null; boolean isRunning = false; BufferedReader in = null; while (!isRunning) { try { es = (EchoService) Naming.lookup("rmi://localhost:1099/testObject"); isRunning = true; } catch (Exception e) { // e.printStackTrace(); System.out.println("\nObjekt nicht gefunden. Programm wird beendet."); } try { Thread.sleep(2000); } catch (Exception e) { e.printStackTrace(); } } // System.exit(1); try { isRunning = true; in = new BufferedReader(new InputStreamReader(System.in)); System.out.print(PROMPT_CLIENT); request = in.readLine(); while (isRunning) { if (request != null && !request.equals(EXIT)) { uid = es.setouruid(); System.out.println(es.getc(uid)); //es.request(request); //response = es.getResponse(); System.out.println("EchoServer> " + response); System.out.print(PROMPT_CLIENT); request = in.readLine(); } else { isRunning = false; } } } catch (Exception e) { e.printStackTrace(); } }}
Möchten Sie kostenlos Ihre eigenen Notizen mit GoConqr erstellen? Mehr erfahren.