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