-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAirserver.java
51 lines (41 loc) · 1.43 KB
/
Airserver.java
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
46
47
48
49
50
51
package airhockey;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.UnknownHostException;
import java.rmi.Naming;
import java.rmi.RemoteException;
/**
* Reads the policy-files to allow others to connect to you and creates a Gamecontroller object
* and binds it for the rmiregistry for the players to start using it.
* @author joel
*
*/
public class Airserver {
public static void main(String[] args) throws RemoteException {
String s = "";
//int port = 1105;
try {
InetAddress i = InetAddress.getLocalHost();
s = i.getHostName();
} catch (UnknownHostException e1) {
e1.printStackTrace();
}
//Get your ip from the Internet, start the rmiregistry from command line first before running the server
System.setProperty("-Djava.rmi.server.hostname", s);
System.setProperty("java.security.policy", "file:./airhockey.policy");
System.setProperty("java.net.SocketPermission", "file:./Connection.policy");
// Registry registry = null;
// Registry registry is never used?
try {
Gamecontroller controller = new Gamecontroller();
System.out.println("Let's start the bind!");
Naming.rebind("controller", controller);
System.out.println("Bind complete.");
} catch (RemoteException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
}
System.out.println("End of Airserver-file.");
}
}