本文整理汇总了Java中org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder类的典型用法代码示例。如果您正苦于以下问题:Java DelimiterBasedFrameDecoder类的具体用法?Java DelimiterBasedFrameDecoder怎么用?Java DelimiterBasedFrameDecoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DelimiterBasedFrameDecoder类属于org.jboss.netty.handler.codec.frame包,在下文中一共展示了DelimiterBasedFrameDecoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPipeline
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; //导入依赖的package包/类
@Override
public ChannelPipeline getPipeline() throws Exception
{
ChannelPipeline pipeline = Channels.pipeline();
// Add the text line codec combination first,
DelimiterBasedFrameDecoder frameDecoder = new DelimiterBasedFrameDecoder(
maxCommandLength, Delimiters.lineDelimiter());
pipeline.addLast("framer", frameDecoder);
pipeline.addLast("decoder", new WordSplitter());
pipeline.addLast("encoder", new StringEncoder());
// and then business logic.
pipeline.addLast("handler", this);
return pipeline;
}
示例2: getPipeline
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; //导入依赖的package包/类
@Override
public ChannelPipeline getPipeline() throws Exception
{
// Create a default pipeline implementation.
ChannelPipeline pipeline = pipeline();
// Add the text line codec combination first,
pipeline.addLast("framer", new DelimiterBasedFrameDecoder(3000000,
ChannelBuffers.wrappedBuffer(new byte[] {'E','O','F'})));
//pipeline.addLast("framer", new DelimiterBasedFrameDecoder(Integer.MAX_VALUE,
// Delimiters.lineDelimiter()));
//pipeline.addLast("eofFramer", new TextProtocolFrameDecoder());
pipeline.addLast("decoder", new StringDecoder());
pipeline.addLast("encoder", new StringEncoder());
// Insert OrderedMemoryAwareThreadPoolExecutor before your blocking handler
pipeline.addLast("pipelineExecutor", new ExecutionHandler(this.eventExecutor));
// and then business logic.
pipeline.addLast("handler", new TextProtocolHandler());
return pipeline;
}
示例3: getPipelineFactory
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; //导入依赖的package包/类
public ChannelPipelineFactory getPipelineFactory() {
executionHandler = new NaviExecutionHandler();
// execution = new ExecutionHandler(Executors.newCachedThreadPool());
return new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("idleState", new IdleStateHandler(timer,
getChildChannelIdleTime(), getChildChannelIdleTime(),
getChildChannelIdleTime()));
//StateCheckChannelHandler加入心跳机制 读空闲 断开连接 写空闲发送心跳数据
// pipeline.addLast("idleHandler", new StateCheckChannelHandler());
pipeline.addLast("decoder", new DelimiterBasedFrameDecoder(getMaxPacketSize(), getDelimiter()));
pipeline.addLast("execution", executionHandler);
// pipeline.addLast("execution", execution);
pipeline.addLast("handler", getNaviTCPHandler());
return pipeline;
}
};
}
示例4: initGps103Server
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; //导入依赖的package包/类
private void initGps103Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
byte delimiter1[] = { (byte) '\r', (byte) '\n' };
byte delimiter2[] = { (byte) '\n' };
byte delimiter3[] = { (byte) ';' };
pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(1024,
ChannelBuffers.wrappedBuffer(delimiter1),
ChannelBuffers.wrappedBuffer(delimiter2),
ChannelBuffers.wrappedBuffer(delimiter3)));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectDecoder", new Gps103ProtocolDecoder(ServerManager.this));
}
});
}
}
示例5: initGl200Server
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; //导入依赖的package包/类
private void initGl200Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
byte delimiter1[] = { (byte) '$' };
byte delimiter2[] = { (byte) '\0' };
pipeline.addLast("frameDecoder",
new DelimiterBasedFrameDecoder(1024,
ChannelBuffers.wrappedBuffer(delimiter1),
ChannelBuffers.wrappedBuffer(delimiter2)));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectDecoder", new Gl200ProtocolDecoder(ServerManager.this));
}
});
}
}
示例6: getPipeline
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; //导入依赖的package包/类
@Override
public ChannelPipeline getPipeline() throws Exception
{
ChannelPipeline pipeline = Channels.pipeline();
// Add the text line codec combination first,
DelimiterBasedFrameDecoder frameDecoder = new DelimiterBasedFrameDecoder(
1024, Delimiters.lineDelimiter());
pipeline.addLast("framer", frameDecoder);
pipeline.addLast("decoder", new WordSplitter());
pipeline.addLast("encoder", new StringEncoder());
// and then business logic.
pipeline.addLast("handler", this);
return pipeline;
}
示例7: getPipeline
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; //导入依赖的package包/类
@Override
public ChannelPipeline getPipeline() {
ChannelPipeline pipeline = Channels.pipeline();
// decoders
pipeline.addLast("framer", new DelimiterBasedFrameDecoder(MAX_REQUEST_LENGTH, DOUBLE_LINE_FEED_DELIMITER));
pipeline.addLast("string-decoder", new StringDecoder(JAGGRAB_CHARSET));
pipeline.addLast("jaggrab-decoder", new JagGrabRequestDecoder());
// encoders
pipeline.addLast("jaggrab-encoder", new JagGrabResponseEncoder());
// handler
pipeline.addLast("timeout", new IdleStateHandler(timer, NetworkConstants.IDLE_TIME, 0, 0));
pipeline.addLast("handler", handler);
return pipeline;
}
示例8: start
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; //导入依赖的package包/类
private void start()
{
// Configure the server.
ServerBootstrap bootstrap = new ServerBootstrap(
new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),
Executors.newCachedThreadPool()));
// Set up the pipeline factory to accept line delimited input.
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception
{
return Channels.pipeline(
new DelimiterBasedFrameDecoder(1024, Delimiters.lineDelimiter()),
new RetraceServerHandler());
}
});
// Bind and start to accept incoming connections.
InetSocketAddress address = new InetSocketAddress(host, port);
bootstrap.bind(address);
System.out.println("RetraceSrv listening on " + host + ":" + port);
}
示例9: getPipeline
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; //导入依赖的package包/类
@Override
public ChannelPipeline getPipeline() {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("U-maintenanceHandler", maintenanceHandler);
pipeline.addLast("U-channels", nrtmChannelsRegistry);
pipeline.addLast("U-acl", aclHandler);
pipeline.addLast("U-delimiter", new DelimiterBasedFrameDecoder(128, true, LINE_DELIMITER));
pipeline.addLast("U-string-decoder", stringDecoder);
pipeline.addLast("D-string-encoder", stringEncoder);
pipeline.addLast("UD-execution", executionHandler);
pipeline.addLast("U-query-handler", new NrtmQueryHandler(serialDao, dummifier, clientSynchronisationScheduler, nrtmLog, version, source, updateInterval));
pipeline.addLast("U-exception-handler", exceptionHandler);
return pipeline;
}
示例10: start
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; //导入依赖的package包/类
public void start() {
ExecutorService bossPool = Executors.newCachedThreadPool();
log.info("Creating worker thread pool with " + workers + " threads.");
ExecutorService workerPool = Executors.newFixedThreadPool(workers);
bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(bossPool, workerPool));
jmxRequestHandler = new JmxRequestHandler();
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(
new DelimiterBasedFrameDecoder(1024 * 1024, ChannelBuffers
.copiedBuffer("\n", CharsetUtil.UTF_8)), new StringDecoder(), new StringEncoder(),
jmxRequestHandler);
};
});
bootstrap.bind(listenAddress);
log.info("Starting listening to {}", listenAddress);
}
示例11: getPipelineFactory
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; //导入依赖的package包/类
public ChannelPipelineFactory getPipelineFactory() {
executionHandler = new NaviExecutionHandler();
return new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("decoder", new DelimiterBasedFrameDecoder(getMaxPacketSize(), getDelimiter()));
pipeline.addLast("execution", executionHandler);
pipeline.addLast("handler", getNaviUDPHandler());
return pipeline;
}
};
}
示例12: startup
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; //导入依赖的package包/类
public void startup(){
try {
bossExecutor = Executors.newCachedThreadPool();
workerExecutor = Executors.newCachedThreadPool();
bootstrap = new ServerBootstrap(
new NioServerSocketChannelFactory(
bossExecutor,workerExecutor));
final NettyServerHandler nettyServerHandler = new NettyServerHandler();
// 设置一个处理客户端消息和各种消息事件的类(Handler)
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast(
"decoder",
new DelimiterBasedFrameDecoder(Integer.MAX_VALUE,
false, true, ChannelBuffers.copiedBuffer(
delimiter,
Charset.forName(encoding))));
pipeline.addLast("handler", nettyServerHandler);
return pipeline;
}
});
bootstrap.setOption("child.receiveBufferSize", receiveBufferSize);
bootstrap.setOption("child.keepAlive", true);
// bootstrap.setOption("child.tcpNoDelay", true);
bootstrap.bind(new InetSocketAddress(InetAddress.getByName(host),
port));
logger.warn("netty server start up success port:{}.", port);
} catch (Exception e) {
logger.error(e.getMessage());
System.exit(1);
}
}
示例13: emit
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; //导入依赖的package包/类
@Override
public void emit() {
// TODO Auto-generated method stub
// Server服务启动器
try {
bossExecutor = Executors.newCachedThreadPool();
workerExecutor = Executors.newCachedThreadPool();
bootstrap = new ServerBootstrap(
new NioServerSocketChannelFactory(
bossExecutor,workerExecutor));
final NettyServerHandler nettyServerHandler = new NettyServerHandler(
this);
// 设置一个处理客户端消息和各种消息事件的类(Handler)
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
if(isExtract){
pipeline.addLast("zlibDecoder", new ZlibDecoder(ZlibWrapper.GZIP));
}
pipeline.addLast(
"decoder",
new DelimiterBasedFrameDecoder(Integer.MAX_VALUE,
false, true, ChannelBuffers.copiedBuffer(
delimiter,
Charset.forName(encoding))));
pipeline.addLast("handler", nettyServerHandler);
return pipeline;
}
});
bootstrap.setOption("child.receiveBufferSize", receiveBufferSize);
bootstrap.setOption("child.keepAlive", true);
bootstrap.setOption("child.tcpNoDelay", true);
bootstrap.bind(new InetSocketAddress(InetAddress.getByName(host),
port));
} catch (Exception e) {
logger.error(e.getMessage());
System.exit(1);
}
}
示例14: newDelimiterBasedFrameDecoder
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; //导入依赖的package包/类
public static ChannelHandlerFactory newDelimiterBasedFrameDecoder(final int maxFrameLength, final ChannelBuffer[] delimiters) {
return new ChannelHandlerFactory() {
@Override
public ChannelHandler newChannelHandler() {
return new DelimiterBasedFrameDecoder(maxFrameLength, true, delimiters);
}
};
}
示例15: getPipeline
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; //导入依赖的package包/类
@Override
public ChannelPipeline getPipeline() throws Exception {
clientInvoked = true;
ChannelPipeline channelPipeline = Channels.pipeline();
channelPipeline.addLast("decoder-DELIM", new DelimiterBasedFrameDecoder(maxLineSize, true, Delimiters.lineDelimiter()));
channelPipeline.addLast("decoder-SD", new StringDecoder(CharsetUtil.UTF_8));
channelPipeline.addLast("encoder-SD", new StringEncoder(CharsetUtil.UTF_8));
channelPipeline.addLast("handler", new ClientChannelHandler(producer));
return channelPipeline;
}