-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.java
More file actions
45 lines (41 loc) · 1.8 KB
/
Client.java
File metadata and controls
45 lines (41 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.io.*;
import java.net.MalformedURLException;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.Scanner;
public class Client extends UnicastRemoteObject implements GraphInterface{
private static final long serialVersionUID = 1L;
public GraphInterface server;
public static String ip;
public static int port = 8889;
private static BufferedReader input_ ;
public static boolean canplaymore=false;
public static void main(String[] args) throws MalformedURLException, RemoteException, NotBoundException, IOException {
System.out.println("The client has now started running.");
input_ = new BufferedReader(new InputStreamReader(System.in));
if (args.length < 1) {
System.out.println("IP not provided. Running on 127.0.0.1");
ip = "127.0.0.1";
} else {
ip = args[0];
}
new Client();
}
protected Client() throws MalformedURLException, RemoteException, NotBoundException, IOException {
Registry registry = LocateRegistry.getRegistry(ip, port);
System.out.println("Starting to connect to server");
this.server = (GraphInterface) registry.lookup("RMIServer");
input_ = new BufferedReader(new InputStreamReader(System.in));
this.server.joinServer(this);
System.out.println("You are now conected to server");
while (1 == 1) {
String command = input_.readLine();
String ret = this.server.getMessage(command);
System.out.println(ret);
}
}
public String getMessage (String message) throws RemoteException, IOException {return "";}
public void joinServer(GraphInterface client) throws RemoteException {}
}