7 static Map<String,String[]> $usr = null;
\r
8 static TCP $tcp = null;
\r
9 static UDP $udp = null;
\r
11 static public void main(String[] $args)throws Exception{
\r
12 if($args.length != 2){
\r
13 System.out.println("usage: java Server.Main <tcpPort> <udpPort>");
\r
16 System.out.println("SERVER Starting...");
\r
18 $usr = Collections.synchronizedMap(new HashMap());
\r
19 BufferedReader $bufr = new BufferedReader(new InputStreamReader(ClassLoader.getSystemResourceAsStream("users.properties")));
\r
21 while(($line = $bufr.readLine()) != null){
\r
22 $line = $line.trim();
\r
23 if($line.length() > 1 && $line.charAt(0) == '=')continue;
\r
24 if($line.length() <= 1)continue;
\r
25 String[] $tmp = $line.split("=");
\r
26 String[] $udata = new String[3];
\r
27 $udata[0]=$tmp[0].trim(); //usrnme
\r
28 if($tmp.length >= 2)$udata[1]=$tmp[1].trim(); else throw new Exception("All users have to have a password! check your user-file");//passwd
\r
29 $udata[2]="never seen online!";
\r
30 $usr.put($udata[0],$udata);
\r
32 System.out.println("SERVER Users.");
\r
34 $tcp = new TCP(Integer.parseInt($args[0]));
\r
35 System.out.println("SERVER TCP: "+$args[0]);
\r
37 $udp = new UDP(Integer.parseInt($args[1]));
\r
38 System.out.println("SERVER UDP: "+$args[1]);
\r
40 System.out.println("SERVER Running. Hit ENTER for shutdown.");
\r
42 int $i = Helper.readByte(System.in);
\r
43 System.out.println($i);
\r
44 if($i == 10 || $i == 13)break;
\r
46 System.out.println("SERVER shutting down...");
\r
50 //save userfile - NOT to implement
\r
52 System.out.println("SERVER bye!");
\r