mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
support android 6 (slow networkplay) tested with two Android 6 device
This commit is contained in:
@@ -19,10 +19,9 @@ public class CustomObjectEncoder extends MessageToByteEncoder<Serializable> {
|
||||
protected void encode(ChannelHandlerContext ctx, Serializable msg, ByteBuf out) throws Exception {
|
||||
int startIdx = out.writerIndex();
|
||||
ByteBufOutputStream bout = new ByteBufOutputStream(out);
|
||||
ElsaObjectOutputStream oout = null;
|
||||
ObjectOutputStream ooutOld = null;
|
||||
|
||||
if (GuiBase.getpropertyConfig()){
|
||||
ElsaObjectOutputStream oout = null;
|
||||
try {
|
||||
bout.write(LENGTH_PLACEHOLDER);
|
||||
oout = new ElsaObjectOutputStream(bout);
|
||||
@@ -35,21 +34,22 @@ public class CustomObjectEncoder extends MessageToByteEncoder<Serializable> {
|
||||
bout.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ObjectOutputStream oout = null;
|
||||
try {
|
||||
bout.write(LENGTH_PLACEHOLDER);
|
||||
ooutOld = new ObjectOutputStream(bout);
|
||||
ooutOld.writeObject(msg);
|
||||
ooutOld.flush();
|
||||
oout = new ObjectOutputStream(bout);
|
||||
oout.writeObject(msg);
|
||||
oout.flush();
|
||||
} finally {
|
||||
if (ooutOld != null) {
|
||||
ooutOld.close();
|
||||
if (oout != null) {
|
||||
oout.close();
|
||||
} else {
|
||||
bout.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int endIdx = out.writerIndex();
|
||||
out.setInt(startIdx, endIdx - startIdx - 4);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public abstract class GameProtocolHandler<T> extends ChannelInboundHandlerAdapte
|
||||
}
|
||||
|
||||
final Object[] args = event.getObjects();
|
||||
//protocolMethod.checkArgs(args);
|
||||
protocolMethod.checkArgs(args);
|
||||
|
||||
final Object toInvoke = getToInvoke(ctx);
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ public final class GameProtocolSender {
|
||||
}
|
||||
|
||||
public void send(final ProtocolMethod method, final Object... args) {
|
||||
//method.checkArgs(args);
|
||||
method.checkArgs(args);
|
||||
remote.send(new GuiGameEvent(method, args));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T sendAndWait(final ProtocolMethod method, final Object... args) {
|
||||
//method.checkArgs(args);
|
||||
method.checkArgs(args);
|
||||
try {
|
||||
final Object returned = remote.sendAndWait(new GuiGameEvent(method, args));
|
||||
method.checkReturnValue(returned);
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.Map;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.deck.CardPool;
|
||||
import forge.game.GameEntityView;
|
||||
@@ -155,6 +156,8 @@ public enum ProtocolMethod {
|
||||
}
|
||||
|
||||
public void checkArgs(final Object[] args) {
|
||||
if (GuiBase.getpropertyConfig())
|
||||
return; //uses custom serializer for Android 8+..
|
||||
for (int iArg = 0; iArg < args.length; iArg++) {
|
||||
Object arg = null;
|
||||
Class<?> type = null;
|
||||
|
||||
Reference in New Issue
Block a user