diff options
author | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-18 15:01:21 +0200 |
---|---|---|
committer | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-18 15:01:21 +0200 |
commit | bc835d499f2fe3c8b9c5b6bc9cfca9d9666854e9 (patch) | |
tree | 6d25b4a32749ba85d7793975b15aacc3ba6fb91a /src/jrummikub/control/network | |
parent | 823ef9d4fe63cb14a114dd01fda54387998071d5 (diff) | |
download | JRummikub-bc835d499f2fe3c8b9c5b6bc9cfca9d9666854e9.tar JRummikub-bc835d499f2fe3c8b9c5b6bc9cfca9d9666854e9.zip |
Fix many comments, fix tests, fix complexity
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@462 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control/network')
4 files changed, 69 insertions, 27 deletions
diff --git a/src/jrummikub/control/network/ConnectionControl.java b/src/jrummikub/control/network/ConnectionControl.java index ca8537d..28684b2 100644 --- a/src/jrummikub/control/network/ConnectionControl.java +++ b/src/jrummikub/control/network/ConnectionControl.java @@ -299,6 +299,11 @@ class ConnectionControl implements IConnectionControl { String messageType = extension.getValue("messageType"); + handleMessageTypes(extension, sender, messageType); + } + + private void handleMessageTypes(DefaultPacketExtension extension, + String sender, String messageType) { if (messageType.equals("game_offer")) { UUID uuid = UUID.fromString(extension.getValue("uuid")); GameSettings settings = (GameSettings) Base64 diff --git a/src/jrummikub/control/network/GameJoinControl.java b/src/jrummikub/control/network/GameJoinControl.java index 4adc61d..489199e 100644 --- a/src/jrummikub/control/network/GameJoinControl.java +++ b/src/jrummikub/control/network/GameJoinControl.java @@ -10,8 +10,21 @@ import jrummikub.util.IListener1; import jrummikub.view.ISettingsPanel.SettingsMode; import jrummikub.view.IView; +/** + * Control for joining a network game + */ public class GameJoinControl extends AbstractGameBeginControl { + /** + * Creates new game join control + * + * @param connectionControl + * the current connection control for events and messages + * @param gameData + * the game data for settings, game id + * @param view + * the view + */ public GameJoinControl(final IConnectionControl connectionControl, final GameData gameData, final IView view) { super(connectionControl, view, gameData, SettingsMode.NETWORK_JOIN); @@ -54,6 +67,9 @@ public class GameJoinControl extends AbstractGameBeginControl { } } + /** + * Starts the join control and sets the settings panel in game join mode + */ public void startGameJoin() { view.showSettingsPanel(true); } diff --git a/src/jrummikub/control/network/GameOfferControl.java b/src/jrummikub/control/network/GameOfferControl.java index af060fd..0c94c1f 100644 --- a/src/jrummikub/control/network/GameOfferControl.java +++ b/src/jrummikub/control/network/GameOfferControl.java @@ -11,8 +11,21 @@ import jrummikub.util.IListener1; import jrummikub.view.ISettingsPanel.SettingsMode; import jrummikub.view.IView; +/** + * Control for network game host + */ public class GameOfferControl extends AbstractGameBeginControl { + /** + * Creates new game offer control + * + * @param connectionControl + * for events (listening and handling) + * @param settings + * the game settings for player list, colors, names + * @param view + * the view + */ public GameOfferControl(final IConnectionControl connectionControl, final GameSettings settings, final IView view) { super(connectionControl, view, @@ -57,6 +70,10 @@ public class GameOfferControl extends AbstractGameBeginControl { })); } + /** + * sends the game offer and starts the settings panel for host using network + * offer type + */ public void startGameOffer() { connectionControl.offerGame(gameData); diff --git a/src/jrummikub/control/network/NetworkControl.java b/src/jrummikub/control/network/NetworkControl.java index 95f48a4..a8faac5 100644 --- a/src/jrummikub/control/network/NetworkControl.java +++ b/src/jrummikub/control/network/NetworkControl.java @@ -44,26 +44,27 @@ public class NetworkControl { this.view = view; connectionControl = new ConnectionControl(loginData); + addConnectionSetupListeners(loginData, view); addConnectionControlListeners(loginData, view); - connections.add(view.getGameListPanel().getJoinEvent() - .add(new IListener1<GameData>() { + connections.add(view.getGameListPanel().getJoinEvent().add( + new IListener1<GameData>() { @Override public void handle(GameData gameData) { join(gameData); } })); - connections.add(view.getGameListPanel().getOpenNewGameEvent() - .add(new IListener() { + connections.add(view.getGameListPanel().getOpenNewGameEvent().add( + new IListener() { @Override public void handle() { createSettingsControl(); } })); - connections.add(view.getGameListPanel().getCancelEvent() - .add(new IListener() { + connections.add(view.getGameListPanel().getCancelEvent().add( + new IListener() { @Override public void handle() { abort(); @@ -87,25 +88,6 @@ public class NetworkControl { */ public void addConnectionControlListeners(final LoginData loginData, final IView view) { - connections.add(connectionControl.getConnectedEvent().add( - new IListener() { - @Override - public void handle() { - view.getGameListPanel().setChannelName( - loginData.getChannelName()); - view.showGameListPanel(true); - } - })); - - connections.add(connectionControl.getConnectionFailedEvent().add( - new IListener() { - @Override - public void handle() { - // TODO Auto-generated method stub - - } - })); - connections.add(connectionControl.getGameOfferEvent().add( new IListener1<GameData>() { @Override @@ -149,6 +131,28 @@ public class NetworkControl { })); } + private void addConnectionSetupListeners(final LoginData loginData, + final IView view) { + connections.add(connectionControl.getConnectedEvent().add( + new IListener() { + @Override + public void handle() { + view.getGameListPanel().setChannelName( + loginData.getChannelName()); + view.showGameListPanel(true); + } + })); + + connections.add(connectionControl.getConnectionFailedEvent().add( + new IListener() { + @Override + public void handle() { + // TODO Auto-generated method stub + + } + })); + } + private void updateGameList() { List<GameData> gameList = new ArrayList<GameData>(); @@ -220,8 +224,8 @@ public class NetworkControl { } view.showGameListPanel(false); - settingsControl = new NetworkSettingsControl( - connectionControl.getNickname(), view, new GameSettings()); + settingsControl = new NetworkSettingsControl(connectionControl + .getNickname(), view, new GameSettings()); settingsControl.getOfferGameEvent().add(new IListener1<GameSettings>() { @Override public void handle(GameSettings settings) { |