本文整理汇总了Java中org.jboss.netty.handler.codec.frame.FrameDecoder类的典型用法代码示例。如果您正苦于以下问题:Java FrameDecoder类的具体用法?Java FrameDecoder怎么用?Java FrameDecoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FrameDecoder类属于org.jboss.netty.handler.codec.frame包,在下文中一共展示了FrameDecoder类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.jboss.netty.handler.codec.frame.FrameDecoder; //导入依赖的package包/类
private static TCPServer start(int port, final ChannelUpstreamHandler serverHandler, final FrameDecoder decoder,
final ChannelDownstreamHandler encoder, final boolean nio) {
TCPServer server = new TCPServer(port);
server.bootstrap = new ServerBootstrap( getChannelFactory(nio) );
// Set up the pipeline factory.
server.bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(
decoder,
encoder,
serverHandler);
}
});
// Bind and start to accept incoming connections.
server.channel = server.bootstrap.bind(new InetSocketAddress(port));
return server;
}
示例2: start
import org.jboss.netty.handler.codec.frame.FrameDecoder; //导入依赖的package包/类
private static TCPClient start(String host, int port, final ChannelUpstreamHandler clientHandler, final ChannelDownstreamHandler encoder,
final FrameDecoder decoder, boolean nio){
TCPClient client = new TCPClient(host, port);
client.clientHandler= clientHandler;
// Configure the client.
client.bootstrap = new ClientBootstrap( getClientSocketChannelFactory(nio));
// Set up the pipeline factory.
client.bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(
encoder,
decoder,
clientHandler);
}
});
// Start the connection attempt.
client.future = client.bootstrap.connect(new InetSocketAddress(host, port));
if (client.getFuture().awaitUninterruptibly(TIME_OUT) && client.getFuture().getChannel().isConnected())
return client ; //logger.info("wait ok");
else {
client.future.getChannel().close();
client.bootstrap.releaseExternalResources();
throw new ConnectionException("not able to connect "+ client.toString());
}
}
示例3: constructRpcFrameDecoder
import org.jboss.netty.handler.codec.frame.FrameDecoder; //导入依赖的package包/类
public static FrameDecoder constructRpcFrameDecoder() {
return new RpcFrameDecoder();
}
示例4: startOio
import org.jboss.netty.handler.codec.frame.FrameDecoder; //导入依赖的package包/类
/**
* decoder must be thread safe, other wise data corruption
* @param port
* @param serverHandler
* @param decoder
* @param encoder
* @return
*/
public static TCPServer startOio(int port, final ChannelUpstreamHandler serverHandler, final FrameDecoder decoder,
final ChannelDownstreamHandler encoder) {
return start(port, serverHandler, decoder, encoder, false);
}
示例5: startOio
import org.jboss.netty.handler.codec.frame.FrameDecoder; //导入依赖的package包/类
/**
*
* @param host
* @param port
* @param clientHandler
* @param encoder
* @param decoder must be thread safe
* @return
*/
public static TCPClient startOio(String host, int port, final ChannelUpstreamHandler clientHandler, final ChannelDownstreamHandler encoder,
final FrameDecoder decoder){
return start( host, port, clientHandler, encoder, decoder, false);
}