mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
Server: fixed missing data compress for some server's responses;
This commit is contained in:
parent
5524224d63
commit
0faecb2fb6
5 changed files with 27 additions and 13 deletions
|
@ -18,7 +18,6 @@ import mage.interfaces.callback.CallbackClient;
|
|||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.remote.ActionData;
|
||||
import mage.remote.Session;
|
||||
import mage.utils.CompressUtil;
|
||||
import mage.view.*;
|
||||
import mage.view.ChatMessage.MessageType;
|
||||
import org.apache.log4j.Logger;
|
||||
|
@ -44,8 +43,8 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
|
||||
@Override
|
||||
public synchronized void processCallback(final ClientCallback callback) {
|
||||
callback.decompressData();
|
||||
SaveObjectUtil.saveObject(callback.getData(), callback.getMethod().toString());
|
||||
callback.setData(CompressUtil.decompress(callback.getData()));
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
try {
|
||||
logger.debug(callback.getMessageId() + " -- " + callback.getMethod());
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
|
||||
|
||||
package mage.interfaces.callback;
|
||||
|
||||
import mage.remote.traffic.ZippedObject;
|
||||
import mage.utils.CompressUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ClientCallback implements Serializable {
|
||||
|
@ -16,12 +16,14 @@ public class ClientCallback implements Serializable {
|
|||
private ClientCallbackMethod method;
|
||||
private int messageId;
|
||||
|
||||
public ClientCallback() {}
|
||||
|
||||
public ClientCallback(ClientCallbackMethod method, UUID objectId, Object data) {
|
||||
this(method, objectId, data, true);
|
||||
}
|
||||
|
||||
public ClientCallback(ClientCallbackMethod method, UUID objectId, Object data, boolean useCompress) {
|
||||
this.method = method;
|
||||
this.objectId = objectId;
|
||||
this.data = data;
|
||||
this.setData(data, useCompress);
|
||||
}
|
||||
|
||||
public ClientCallback(ClientCallbackMethod method, UUID objectId) {
|
||||
|
@ -42,11 +44,26 @@ public class ClientCallback implements Serializable {
|
|||
}
|
||||
|
||||
public Object getData() {
|
||||
if (this.data instanceof ZippedObject) {
|
||||
throw new IllegalStateException("Client data must be decompressed first");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
public void setData(Object data, boolean useCompress) {
|
||||
if (!useCompress || data == null || data instanceof ZippedObject) {
|
||||
this.data = data;
|
||||
} else {
|
||||
this.data = CompressUtil.compress(data);
|
||||
}
|
||||
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public void decompressData() {
|
||||
if (this.data instanceof ZippedObject) {
|
||||
this.data = CompressUtil.decompress(this.data);
|
||||
}
|
||||
}
|
||||
|
||||
public ClientCallbackMethod getMethod() {
|
||||
|
|
|
@ -14,7 +14,7 @@ public final class CompressUtil {
|
|||
* Defines should data be compressed or not. True by default. Read from
|
||||
* system property:
|
||||
*/
|
||||
private static boolean compressData = true;
|
||||
private static boolean compressData;
|
||||
|
||||
/**
|
||||
* Defines the system property name to disable any compressing.
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
package mage.server.game;
|
||||
|
||||
import mage.game.Game;
|
||||
|
@ -101,7 +99,6 @@ public class GameSessionWatcher {
|
|||
GameView gameView = new GameView(game.getState(), game, null, userId);
|
||||
processWatchedHands(userId, gameView);
|
||||
return gameView;
|
||||
|
||||
}
|
||||
|
||||
protected void processWatchedHands(UUID userId, GameView gameView) {
|
||||
|
|
|
@ -35,6 +35,7 @@ public class LoadCallbackClient implements CallbackClient {
|
|||
|
||||
@Override
|
||||
public void processCallback(ClientCallback callback) {
|
||||
callback.decompressData();
|
||||
controlCount = 0;
|
||||
|
||||
// ignore bloaded logs
|
||||
|
|
Loading…
Reference in a new issue