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.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")));