mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 20:11:59 -08: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
|
|
@ -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,13 +44,28 @@ 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() {
|
||||
return method;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue