summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/control/network')
-rw-r--r--src/jrummikub/control/network/LoginControl.java25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/jrummikub/control/network/LoginControl.java b/src/jrummikub/control/network/LoginControl.java
index e03625d..07e0b71 100644
--- a/src/jrummikub/control/network/LoginControl.java
+++ b/src/jrummikub/control/network/LoginControl.java
@@ -1,5 +1,9 @@
package jrummikub.control.network;
+import java.util.ArrayList;
+import java.util.List;
+
+import jrummikub.util.Connection;
import jrummikub.util.Event;
import jrummikub.util.Event3;
import jrummikub.util.IEvent;
@@ -12,30 +16,30 @@ public class LoginControl {
private IView view;
private Event3<String, String, String> loginEvent = new Event3<String, String, String>();
private Event cancelEvent = new Event();
+ private List<Connection> connections = new ArrayList<Connection>();
public LoginControl(final IView view) {
this.view = view;
- view.getLoginPanel().getLoginEvent()
+ connections.add(view.getLoginPanel().getLoginEvent()
.add(new IListener3<String, String, String>() {
@Override
public void handle(String userName, String password,
String channelName) {
- view.showLoginPanel(false);
+ abort();
loginEvent.emit(userName, password, channelName);
}
- });
+ }));
- view.getLoginPanel().getCancelEvent().add(new IListener() {
+ connections.add(view.getLoginPanel().getCancelEvent().add(new IListener() {
@Override
public void handle() {
- view.showLoginPanel(false);
+ abort();
cancelEvent.emit();
}
- });
+ }));
}
public void startLogin() {
- view.clearView();
view.showLoginPanel(true);
}
@@ -47,4 +51,11 @@ public class LoginControl {
return cancelEvent;
}
+ public void abort() {
+ view.showLoginPanel(false);
+ for (Connection c : connections) {
+ c.remove();
+ }
+ }
+
}