Use GZIP in the Factorial example

This commit is contained in:
Trustin Lee 2009-10-21 11:27:12 +00:00
parent 8b7efa5db4
commit 1dc34f0bfd
2 changed files with 8 additions and 8 deletions

View File

@ -21,6 +21,7 @@ import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.handler.codec.compression.ZlibDecoder;
import org.jboss.netty.handler.codec.compression.ZlibEncoder;
import org.jboss.netty.handler.codec.compression.ZlibWrapper;
/**
* Creates a newly configured {@link ChannelPipeline} for a client-side channel.
@ -42,8 +43,9 @@ public class FactorialClientPipelineFactory implements
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = pipeline();
pipeline.addLast("a", new ZlibEncoder());
pipeline.addLast("b", new ZlibDecoder());
// Enable stream compression (you can comment out if unnecessary)
pipeline.addLast("deflater", new ZlibEncoder(ZlibWrapper.GZIP));
pipeline.addLast("inflater", new ZlibDecoder(ZlibWrapper.GZIP));
// Add the number codec first,
pipeline.addLast("decoder", new BigIntegerDecoder());

View File

@ -21,8 +21,7 @@ import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.handler.codec.compression.ZlibDecoder;
import org.jboss.netty.handler.codec.compression.ZlibEncoder;
import org.jboss.netty.handler.logging.LoggingHandler;
import org.jboss.netty.logging.InternalLogLevel;
import org.jboss.netty.handler.codec.compression.ZlibWrapper;
/**
* Creates a newly configured {@link ChannelPipeline} for a server-side channel.
@ -39,10 +38,9 @@ public class FactorialServerPipelineFactory implements
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = pipeline();
pipeline.addLast("l", new LoggingHandler(InternalLogLevel.INFO, true));
pipeline.addLast("a", new ZlibEncoder());
pipeline.addLast("b", new ZlibDecoder());
// Enable stream compression (you can comment out if unnecessary)
pipeline.addLast("deflater", new ZlibEncoder(ZlibWrapper.GZIP));
pipeline.addLast("inflater", new ZlibDecoder(ZlibWrapper.GZIP));
// Add the number codec first,
pipeline.addLast("decoder", new BigIntegerDecoder());