From 73c1072ba68b152aeb85aa71ae751f5d8afb3a68 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Wed, 22 Jun 2011 10:38:11 +0200 Subject: Continued NetworkControlTest git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@592 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/network/NetworkControl.java | 42 +++++++++++++---------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'src/jrummikub') 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() { + @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() { @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() { - @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() { -- cgit v1.2.3