RuneHive-Game
Loading...
Searching...
No Matches
OnDemandPipelineFactory.java
Go to the documentation of this file.
1package dev.advo.fs.net;
2
3
4import org.jboss.netty.channel.ChannelPipeline;
5import org.jboss.netty.channel.ChannelPipelineFactory;
6import org.jboss.netty.channel.Channels;
7import org.jboss.netty.handler.timeout.IdleStateHandler;
8import org.jboss.netty.util.Timer;
9
10import dev.advo.fs.net.ondemand.OnDemandRequestDecoder;
11import dev.advo.fs.net.ondemand.OnDemandResponseEncoder;
12import dev.advo.fs.net.service.ServiceRequestDecoder;
13import dev.advo.fs.net.service.ServiceResponseEncoder;
14
15public final class OnDemandPipelineFactory implements ChannelPipelineFactory {
16
18 private final Timer timer;
19
21 this.handler = handler;
22 this.timer = timer;
23 }
24
25 @Override
26 public ChannelPipeline getPipeline() throws Exception {
27 ChannelPipeline pipeline = Channels.pipeline();
28
29 // decoders
30 pipeline.addLast("serviceDecoder", new ServiceRequestDecoder());
31 pipeline.addLast("decoder", new OnDemandRequestDecoder());
32
33 // encoders
34 pipeline.addLast("serviceEncoder", new ServiceResponseEncoder());
35 pipeline.addLast("encoder", new OnDemandResponseEncoder());
36
37 // handler
38 pipeline.addLast("timeout", new IdleStateHandler(timer, NetworkConstants.IDLE_TIME, 0, 0));
39 pipeline.addLast("handler", handler);
40
41 return pipeline;
42 }
43
44}
OnDemandPipelineFactory(FileServerHandler handler, Timer timer)