summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r--src/jrummikub/control/network/NetworkControl.java42
1 files changed, 23 insertions, 19 deletions
diff --git a/src/jrummikub/control/network/NetworkControl.java b/src/jrummikub/control/network/NetworkControl.java
index 154ea06..d31442b 100644
--- a/src/jrummikub/control/network/NetworkControl.java
+++ b/src/jrummikub/control/network/NetworkControl.java
@@ -59,8 +59,8 @@ public class NetworkControl {
this.connectionControl = connectionControl;
this.saveControl = saveControl;
- addConnectionSetupListeners(loginData, view);
- addConnectionControlListeners(view);
+ addConnectionSetupListeners(loginData);
+ addConnectionControlListeners();
addViewEventListeners();
}
@@ -98,11 +98,8 @@ public class NetworkControl {
/**
* Adds the listeners for connection control events
- *
- * @param view
- * view for events
*/
- public void addConnectionControlListeners(final IView view) {
+ private void addConnectionControlListeners() {
addOfferUpdateListener();
connections.add(connectionControl.getGameWithdrawalEvent().add(
@@ -115,6 +112,24 @@ public class NetworkControl {
updateGameList();
}
}));
+ connections.add(connectionControl.getGameJoinAckEvent().add(
+ new IListener1<Boolean>() {
+ @Override
+ public void handle(Boolean ack) {
+ if (ack) {
+ createGameJoinControl();
+ } else {
+ view.showGameListPanel(true);
+ }
+ }
+ }));
+ addConnectionLostListeners();
+ }
+
+ /**
+ * Adds the listeners for lost connection events
+ */
+ private void addConnectionLostListeners() {
connections.add(connectionControl.getParticipantLeftEvent().add(
new IListener1<String>() {
@Override
@@ -123,23 +138,13 @@ public class NetworkControl {
if (entry.getValue().getHost().equals(nickname)) {
games.remove(entry.getKey());
gameMap.remove(entry.getKey());
+ break;
}
}
updateGameList();
}
}));
- connections.add(connectionControl.getGameJoinAckEvent().add(
- new IListener1<Boolean>() {
- @Override
- public void handle(Boolean ack) {
- if (ack) {
- createGameJoinControl();
- } else {
- view.showGameListPanel(true);
- }
- }
- }));
connections.add(connectionControl.getConnectionLostEvent().add(
new IListener() {
@Override
@@ -181,8 +186,7 @@ public class NetworkControl {
}));
}
- private void addConnectionSetupListeners(final LoginData loginData,
- final IView view) {
+ private void addConnectionSetupListeners(final LoginData loginData) {
connections.add(connectionControl.getConnectedEvent().add(new IListener() {
@Override
public void handle() {