From bf24a9279ae23336cc8e14d6e1c40f1a2a0c33a7 Mon Sep 17 00:00:00 2001 From: Bennet Gerlach Date: Sun, 19 Jun 2011 02:47:38 +0200 Subject: Start game button in a network game sends an event git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@479 72836036-5685-4462-b002-a69064685172 --- .../control/network/ConnectionControl.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/jrummikub/control/network/ConnectionControl.java') diff --git a/src/jrummikub/control/network/ConnectionControl.java b/src/jrummikub/control/network/ConnectionControl.java index 86322b2..6ded0f3 100644 --- a/src/jrummikub/control/network/ConnectionControl.java +++ b/src/jrummikub/control/network/ConnectionControl.java @@ -53,6 +53,8 @@ public class ConnectionControl implements IConnectionControl { private Event2 changeColorEvent = new Event2(); + private Event gameStartEvent = new Event(); + private GameData currentGame; private volatile GameData offeredGame; @@ -128,6 +130,11 @@ public class ConnectionControl implements IConnectionControl { return changeColorEvent; } + @Override + public IEvent getGameStartEvent() { + return gameStartEvent; + } + @Override public void offerGame(GameData data) { offeredGame = data; @@ -221,6 +228,19 @@ public class ConnectionControl implements IConnectionControl { } + @Override + public void startGame() { + final UUID uuid = currentGame.getGameID(); + run(new SendRunner() { + @Override + protected void addData(DefaultPacketExtension extension) { + extension.setValue("messageType", "game_start"); + extension.setValue("uuid", uuid.toString()); + } + }); + + } + private void sendGameOffer() { final GameData data = offeredGame; run(new SendRunner() { @@ -315,6 +335,8 @@ public class ConnectionControl implements IConnectionControl { } else if (messageType.equals("change_color")) { changeColorEvent.emit(sender, (Color) Base64.decodeToObject(extension.getValue("color"))); + } else if (messageType.equals("game_start")) { + gameStartEvent.emit(); } else { System.err.println("Received unrecognized message of type '" + messageType + "'"); -- cgit v1.2.3