Use Netty Default Object Decoder/Encoder

This commit is contained in:
Anthony Calosa
2020-04-03 21:35:05 +08:00
parent bd5cc06504
commit da984227b1
4 changed files with 12 additions and 12 deletions

View File

@@ -1,7 +1,5 @@
package forge.net.client;
import forge.net.CustomObjectDecoder;
import forge.net.CustomObjectEncoder;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
@@ -28,6 +26,8 @@ import forge.net.event.IdentifiableNetEvent;
import forge.net.event.LobbyUpdateEvent;
import forge.net.event.MessageEvent;
import forge.net.event.NetEvent;
import io.netty.handler.codec.serialization.ObjectDecoder;
import io.netty.handler.codec.serialization.ObjectEncoder;
public class FGameClient implements IToServer {
@@ -58,8 +58,8 @@ public class FGameClient implements IToServer {
public void initChannel(final SocketChannel ch) throws Exception {
final ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(
new CustomObjectEncoder(),
new CustomObjectDecoder(CustomObjectDecoder.maxObjectsize, ClassResolvers.cacheDisabled(null)),
new ObjectEncoder(),
new ObjectDecoder(9766*1024, ClassResolvers.cacheDisabled(null)),
new MessageHandler(),
new LobbyUpdateHandler(),
new GameClientHandler(FGameClient.this));

View File

@@ -6,8 +6,6 @@ import forge.interfaces.IGuiGame;
import forge.interfaces.ILobbyListener;
import forge.match.LobbySlot;
import forge.match.LobbySlotType;
import forge.net.CustomObjectDecoder;
import forge.net.CustomObjectEncoder;
import forge.net.event.LobbyUpdateEvent;
import forge.net.event.LoginEvent;
import forge.net.event.LogoutEvent;
@@ -26,6 +24,8 @@ import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.codec.serialization.ClassResolvers;
import io.netty.handler.codec.serialization.ObjectDecoder;
import io.netty.handler.codec.serialization.ObjectEncoder;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
@@ -99,8 +99,8 @@ public final class FServerManager {
public final void initChannel(final SocketChannel ch) throws Exception {
final ChannelPipeline p = ch.pipeline();
p.addLast(
new CustomObjectEncoder(),
new CustomObjectDecoder(CustomObjectDecoder.maxObjectsize, ClassResolvers.cacheDisabled(null)),
new ObjectEncoder(),
new ObjectDecoder(9766*1024, ClassResolvers.cacheDisabled(null)),
new MessageHandler(),
new RegisterClientHandler(),
new LobbyInputHandler(),