summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-06-20 15:46:01 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-06-20 15:46:01 +0200
commit72a16316dc44aaae68530c0f57d342fd919526da (patch)
treef7b0f081dae09dbf24cad42d44822353ec5f5699 /src/jrummikub/control
parent843b37aa801c8627f8dd3ffcbe234153d8eebc84 (diff)
downloadJRummikub-72a16316dc44aaae68530c0f57d342fd919526da.tar
JRummikub-72a16316dc44aaae68530c0f57d342fd919526da.zip
Fix transmission of turn_end messages
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@512 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r--src/jrummikub/control/network/ConnectionControl.java43
1 files changed, 33 insertions, 10 deletions
diff --git a/src/jrummikub/control/network/ConnectionControl.java b/src/jrummikub/control/network/ConnectionControl.java
index 871d06b..7c3ed77 100644
--- a/src/jrummikub/control/network/ConnectionControl.java
+++ b/src/jrummikub/control/network/ConnectionControl.java
@@ -1,6 +1,7 @@
package jrummikub.control.network;
import java.awt.Color;
+import java.io.Serializable;
import java.util.UUID;
import javax.swing.SwingUtilities;
@@ -42,6 +43,32 @@ import org.jivesoftware.smackx.muc.MultiUserChat;
* Connection control managing network connections, essages and events
*/
public class ConnectionControl implements IConnectionControl {
+ private static class TurnEndData implements Serializable {
+ private static final long serialVersionUID = -3800572117130220737L;
+
+ private IHand oldHand;
+ private ITable oldTable;
+ private ITable newTable;
+
+ TurnEndData(IHand oldHand, ITable oldTable, ITable newTable) {
+ this.oldHand = oldHand;
+ this.oldTable = oldTable;
+ this.newTable = newTable;
+ }
+
+ IHand getOldHand() {
+ return oldHand;
+ }
+
+ ITable getOldTable() {
+ return oldTable;
+ }
+
+ ITable getNewTable() {
+ return newTable;
+ }
+ }
+
private final static String ELEMENT_NAME = "rummikub";
private final static String NAMESPACE = "http://home.universe-factory.net/rummikub/";
@@ -313,12 +340,8 @@ public class ConnectionControl implements IConnectionControl {
protected void addData(DefaultPacketExtension extension) {
extension.setValue("messageType", "turn_end");
extension.setValue("uuid", uuid.toString());
- extension.setValue("old_hand",
- Base64.encodeObject(oldHand, Base64.GZIP));
- extension.setValue("old_table",
- Base64.encodeObject(oldTable, Base64.GZIP));
- extension.setValue("new_table",
- Base64.encodeObject(newTable, Base64.GZIP));
+ extension.setValue("data", Base64.encodeObject(new TurnEndData(oldHand,
+ oldTable, newTable), Base64.GZIP));
}
});
}
@@ -447,10 +470,10 @@ public class ConnectionControl implements IConnectionControl {
tableUpdateEvent.emit((ITable) Base64.decodeToObject(extension
.getValue("table")));
} else if (messageType.equals("turn_end")) {
- turnEndEvent.emit(
- (IHand) Base64.decodeToObject(extension.getValue("old_hand")),
- (ITable) Base64.decodeToObject(extension.getValue("old_table")),
- (ITable) Base64.decodeToObject(extension.getValue("new_table")));
+ TurnEndData data = (TurnEndData) Base64.decodeToObject(extension
+ .getValue("data"));
+ turnEndEvent.emit(data.getOldHand(), data.getOldTable(),
+ data.getNewTable());
} else if (messageType.equals("turn_start")) {
turnStartEvent.emit((IRoundState) Base64.decodeToObject(extension
.getValue("state")));