- if(listening && !active)
- conn.removeNotifyListener(this);
- else if(!listening && active)
- conn.addNotifyListener(this);
- }
-
- private int atoi(String a) {
- return(Integer.parseInt(a));
- }
-
- private void fetchhubs() {
- synchronized(hubstate) {
- if(hubstate[0] != "none")
- return;
- hubstate[0] = "fetch";
- }
- Command cmd = new Command("lsnodes");
- cmd.new Listener() {
- public void done(Response r) {
- if(r.code != 200)
- return;
- for(List<String> line : r.lines) {
- Hub h = new Hub(atoi(line.get(0)));
- h.fnet = line.get(1).intern();
- h.name = line.get(2);
- h.numpeers = atoi(line.get(3));
- h.state = new String[] {"syn", "hs", "est", "dead"}[atoi(line.get(4))];
- h.gid = line.get(5);
- hubs.put(h.id, h);
- }
- }
-
- public void error(Exception e) {
- }
- };
- conn.qcmd(new Command("notify fn:act on"), cmd);