Skip to content
Snippets Groups Projects
Commit f4f4b9dc authored by Hai HoDac's avatar Hai HoDac
Browse files

Client:

_ Fixed default username
_ No input arguments needed
Syntax: java -jar Client.jar

Server:
_ Add one compulsory input argument: server ip address
Syntax: java -jar Server.jar <host ip address>
parent fd9c6a61
No related branches found
No related tags found
No related merge requests found
...@@ -93,9 +93,9 @@ public class Client ...@@ -93,9 +93,9 @@ public class Client
} }
public Client(String username) throws RemoteException, NoSuchProviderException, NoSuchAlgorithmException public Client() throws RemoteException, NoSuchProviderException, NoSuchAlgorithmException
{ {
this.defaultUserName = username; this.defaultUserName = DEFAULT_USERNAME;
this.clientUpdate = new ClientUpdate(this); this.clientUpdate = new ClientUpdate(this);
this.chatUpdate = new ChatUpdate(this); this.chatUpdate = new ChatUpdate(this);
this.drawingUpdate = new DrawingUpdate(this); this.drawingUpdate = new DrawingUpdate(this);
...@@ -108,7 +108,7 @@ public class Client ...@@ -108,7 +108,7 @@ public class Client
{ {
try try
{ {
Client client = new Client(args[0]); Client client = new Client();
client.showStartScreen(); client.showStartScreen();
} }
catch (Exception e) catch (Exception e)
......
...@@ -50,7 +50,7 @@ public class Server ...@@ -50,7 +50,7 @@ public class Server
{ {
Server server = new Server(); Server server = new Server();
server.run(); server.run(args[0]);
} }
catch( Exception e ) catch( Exception e )
{ {
...@@ -58,15 +58,15 @@ public class Server ...@@ -58,15 +58,15 @@ public class Server
} }
} }
public void run() throws RemoteException public void run(String serverIP) throws RemoteException
{ {
String serverIP = ""; // String serverIP = "";
try { // try {
InetAddress inetAddress = InetAddress.getLocalHost(); // InetAddress inetAddress = InetAddress.getLocalHost();
serverIP = inetAddress.getHostAddress(); // serverIP = inetAddress.getHostAddress();
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
System.setProperty("java.rmi.server.hostname", serverIP); System.setProperty("java.rmi.server.hostname", serverIP);
...@@ -91,16 +91,18 @@ public class Server ...@@ -91,16 +91,18 @@ public class Server
System.out.println("Server is ready"); System.out.println("Server is ready");
printIP(); printIP(serverIP);
} }
private void printIP() private void printIP(String serverIP)
{ {
InetAddress inetAddress = null; InetAddress inetAddress = null;
try try
{ {
if (serverIP.isEmpty()) {
inetAddress = InetAddress.getLocalHost(); inetAddress = InetAddress.getLocalHost();
} else inetAddress = InetAddress.getByName(serverIP);
} }
catch (UnknownHostException e) catch (UnknownHostException e)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment