X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fjava%2Fdolda%2Fdolcon%2Fprotocol%2FConnection.java;h=03152bce6783aeec86c775bd369fa232043451cd;hb=1505a392760fb7941871183ea9e7c9be90ee2273;hp=31bb172c8712cbbddf2c1214f09a3639f39f427d;hpb=6bc193f2ce2a87a667e2a83aac01135520fdee26;p=doldaconnect.git diff --git a/lib/java/dolda/dolcon/protocol/Connection.java b/lib/java/dolda/dolcon/protocol/Connection.java index 31bb172..03152bc 100644 --- a/lib/java/dolda/dolcon/protocol/Connection.java +++ b/lib/java/dolda/dolcon/protocol/Connection.java @@ -14,13 +14,14 @@ public class Connection { private String aspec; private String state; private Set connls = new HashSet(); + private Set notls = new HashSet(); private Exception error; public interface ConnectListener { public void connected() throws Exception; public void error(Exception cause); } - + public Connection(String aspec) { this.aspec = aspec; state = "idle"; @@ -162,6 +163,18 @@ public class Connection { return(error); } + public void addNotifyListener(NotifyListener l) { + synchronized(notls) { + notls.add(l); + } + } + + public void removeNotifyListener(NotifyListener l) { + synchronized(notls) { + notls.remove(l); + } + } + public synchronized void addConnectListener(ConnectListener l) { if((state != "idle") && (state != "connecting")) throw(new IllegalStateException("Already connected")); @@ -299,6 +312,12 @@ public class Connection { queue.notifyAll(); } resp.cmd.done(resp); + } else { + synchronized(notls) { + for(NotifyListener l : notls) { + l.notified(resp); + } + } } }