support android 6 (slow networkplay) tested with two Android 6 device

This commit is contained in:
Anthony Calosa
2019-11-01 17:34:42 +08:00
parent a5b65eaaed
commit a80c683901
4 changed files with 15 additions and 12 deletions

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;