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/ConnectionControl.java4
-rw-r--r--src/jrummikub/control/network/GameJoinControl.java19
-rw-r--r--src/jrummikub/control/network/GameOfferControl.java5
-rw-r--r--src/jrummikub/control/network/NetworkControl.java7
4 files changed, 26 insertions, 9 deletions
diff --git a/src/jrummikub/control/network/ConnectionControl.java b/src/jrummikub/control/network/ConnectionControl.java
index 6dc1bb5..57e0cc6 100644
--- a/src/jrummikub/control/network/ConnectionControl.java
+++ b/src/jrummikub/control/network/ConnectionControl.java
@@ -125,8 +125,8 @@ class ConnectionControl {
void withdrawGame() {
offeredGame = null;
- currentGame = null;
final UUID uuid = currentGame.getGameID();
+ currentGame = null;
new Thread(new SendRunner() {
@Override
public Message send() {
@@ -137,7 +137,7 @@ class ConnectionControl {
return createMessage(extension);
}
- });
+ }).start();
}
GameData getCurrentGame() {
diff --git a/src/jrummikub/control/network/GameJoinControl.java b/src/jrummikub/control/network/GameJoinControl.java
index 1d29df4..d4a31d3 100644
--- a/src/jrummikub/control/network/GameJoinControl.java
+++ b/src/jrummikub/control/network/GameJoinControl.java
@@ -1,5 +1,7 @@
package jrummikub.control.network;
+import java.util.UUID;
+
import jrummikub.model.GameSettings;
import jrummikub.model.PlayerSettings;
import jrummikub.model.PlayerSettings.Type;
@@ -10,7 +12,6 @@ import jrummikub.view.ISettingsPanel.SettingsMode;
import jrummikub.view.IView;
public class GameJoinControl extends AbstractGameBeginControl {
- private Event backEvent = new Event();
public GameJoinControl(final ConnectionControl connectionControl,
final GameData gameData, final IView view) {
@@ -31,6 +32,16 @@ public class GameJoinControl extends AbstractGameBeginControl {
}
}
}));
+ connections.add(connectionControl.getGameWithdrawalEvent().add(
+ new IListener1<UUID>() {
+ @Override
+ public void handle(UUID uuid) {
+ if (uuid.equals(gameData.getGameID())) {
+ abort();
+ backEvent.emit();
+ }
+ }
+ }));
}
private void fixGameSettings(GameSettings settings) {
@@ -44,10 +55,6 @@ public class GameJoinControl extends AbstractGameBeginControl {
}
}
- public Event getBackEvent() {
- return backEvent;
- }
-
public void startGameJoin() {
view.showSettingsPanel(true);
}
@@ -55,10 +62,10 @@ public class GameJoinControl extends AbstractGameBeginControl {
/**
* Aborts joining and goes back to game list
*/
+ @Override
protected void goBack() {
abort();
connectionControl.leaveGame();
- view.showSettingsPanel(false);
backEvent.emit();
}
diff --git a/src/jrummikub/control/network/GameOfferControl.java b/src/jrummikub/control/network/GameOfferControl.java
index f09eb6e..7e3241f 100644
--- a/src/jrummikub/control/network/GameOfferControl.java
+++ b/src/jrummikub/control/network/GameOfferControl.java
@@ -64,7 +64,10 @@ public class GameOfferControl extends AbstractGameBeginControl {
}
+ @Override
protected void goBack() {
- // TODO
+ abort();
+ connectionControl.withdrawGame();
+ backEvent.emit();
}
}
diff --git a/src/jrummikub/control/network/NetworkControl.java b/src/jrummikub/control/network/NetworkControl.java
index 0e8381b..0a7ea8d 100644
--- a/src/jrummikub/control/network/NetworkControl.java
+++ b/src/jrummikub/control/network/NetworkControl.java
@@ -243,6 +243,13 @@ public class NetworkControl {
return;
}
gameOfferControl = new GameOfferControl(connectionControl, settings, view);
+ gameOfferControl.getBackEvent().add(new IListener() {
+ @Override
+ public void handle() {
+ gameOfferControl=null;
+ view.showGameListPanel(true);
+ }
+ });
gameOfferControl.startGameOffer();
}