| 87 |
Kevin |
1 |
/**************************************************************************
|
|
|
2 |
* Copyright 2011 Jules White
|
|
|
3 |
*
|
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
|
6 |
* You may obtain a copy of the License at
|
|
|
7 |
*
|
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
9 |
*
|
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
13 |
* See the License for the specific language governing permissions and
|
|
|
14 |
* limitations under the License.
|
|
|
15 |
***************************************************************************/
|
|
|
16 |
package org.vt.ece4564.latmb;
|
|
|
17 |
|
|
|
18 |
import static org.jboss.netty.channel.Channels.*;
|
|
|
19 |
|
|
|
20 |
import javax.net.ssl.SSLEngine;
|
|
|
21 |
|
|
|
22 |
import org.jboss.netty.channel.ChannelPipeline;
|
|
|
23 |
import org.jboss.netty.channel.ChannelPipelineFactory;
|
|
|
24 |
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
|
|
|
25 |
import org.jboss.netty.handler.codec.frame.Delimiters;
|
|
|
26 |
import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder;
|
|
|
27 |
import org.jboss.netty.handler.codec.protobuf.ProtobufEncoder;
|
|
|
28 |
import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
|
|
|
29 |
import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;
|
|
|
30 |
import org.jboss.netty.handler.codec.string.StringDecoder;
|
|
|
31 |
import org.jboss.netty.handler.codec.string.StringEncoder;
|
|
|
32 |
import org.jboss.netty.handler.ssl.SslHandler;
|
|
|
33 |
|
|
|
34 |
/**
|
|
|
35 |
* Creates a newly configured {@link ChannelPipeline} for a new channel.
|
|
|
36 |
*
|
|
|
37 |
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
|
|
38 |
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
|
|
39 |
*
|
|
|
40 |
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
|
|
41 |
*
|
|
|
42 |
*/
|
|
|
43 |
public class LATMBServerPipelineFactory implements ChannelPipelineFactory {
|
|
|
44 |
|
|
|
45 |
private boolean useSSL_ = false;
|
|
|
46 |
|
|
|
47 |
public ChannelPipeline getPipeline() throws Exception {
|
|
|
48 |
ChannelPipeline pipeline = pipeline();
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
pipeline.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
|
|
|
52 |
pipeline.addLast("protobufDecoder", new ProtobufDecoder(
|
|
|
53 |
LATMBProtocol.TrackingMessage.getDefaultInstance()));
|
|
|
54 |
|
|
|
55 |
pipeline.addLast("frameEncoder",
|
|
|
56 |
new ProtobufVarint32LengthFieldPrepender());
|
|
|
57 |
pipeline.addLast("protobufEncoder", new ProtobufEncoder());
|
|
|
58 |
|
|
|
59 |
// and then business logic.
|
|
|
60 |
pipeline.addLast("handler", new LATMBServerHandler());
|
|
|
61 |
|
|
|
62 |
return pipeline;
|
|
|
63 |
}
|
|
|
64 |
}
|