Java: Hopefully working HubListeners.
[doldaconnect.git] / lib / java / dolda / dolcon / Test.java
1 package dolda.dolcon;
2
3 import java.util.*;
4
5 class Test {
6     public static void main(String[] args) throws Exception {
7         System.out.print("Password: ");
8         PasswordAuth auth = new PasswordAuth(new Scanner(System.in).nextLine());
9         long st = System.currentTimeMillis();
10         Session sess = new Session(args[0], args[1], auth);
11         sess.addHubListener(new HubListener() {
12                 public void added(Hub h) {
13                     h.addListener(new Hub.Listener() {
14                             public void chState(Hub h) {
15                                 System.out.println(h.getId() + ": " + h.getState());
16                             }
17                             
18                             public void chNumPeers(Hub h) {
19                                 System.out.println(h.getId() + ": " + h.getNumPeers());
20                             }
21                             
22                             public void chName(Hub h) {
23                                 System.out.println(h.getId() + ": " + h.getName());
24                             }
25                         });
26                 }
27                 
28                 public void removed(Hub h) {
29                 }
30             }, true);
31         /*
32         System.out.println(sess.getHubs());
33         sess.close();
34         System.out.println(System.currentTimeMillis() - st);
35         */
36     }
37 }