Fix transmission of turn_end messages
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@512 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
843b37aa80
commit
72a16316dc
1 changed files with 33 additions and 10 deletions
|
@ -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")));
|
||||
|
|
Reference in a new issue