echo 작업중
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
//package com.eactive.httpmockserver.socket;
|
||||
//
|
||||
//import java.nio.ByteOrder;
|
||||
//
|
||||
//import javax.annotation.PreDestroy;
|
||||
//
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import io.netty.bootstrap.ServerBootstrap;
|
||||
//import io.netty.channel.Channel;
|
||||
//import io.netty.channel.ChannelFuture;
|
||||
//import io.netty.channel.ChannelInitializer;
|
||||
//import io.netty.channel.ChannelOption;
|
||||
//import io.netty.channel.ChannelPipeline;
|
||||
//import io.netty.channel.EventLoopGroup;
|
||||
//import io.netty.channel.nio.NioEventLoopGroup;
|
||||
//import io.netty.channel.socket.SocketChannel;
|
||||
//import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
//import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
|
||||
//import io.netty.handler.codec.LengthFieldPrepender;
|
||||
//import io.netty.handler.codec.string.StringDecoder;
|
||||
//import io.netty.util.CharsetUtil;
|
||||
//
|
||||
//@Component
|
||||
//public class EchoSocketServer {
|
||||
// private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
//
|
||||
// private Channel channel;
|
||||
//
|
||||
// public void start() {
|
||||
// EventLoopGroup bossGroup = new NioEventLoopGroup();
|
||||
// EventLoopGroup workerGroup = new NioEventLoopGroup();
|
||||
// try {
|
||||
// ServerBootstrap server = new ServerBootstrap();
|
||||
// // @formatter:off
|
||||
// server.group(bossGroup, workerGroup)
|
||||
// .channel(NioServerSocketChannel.class)
|
||||
// .childHandler(new ChannelInitializer<SocketChannel>() {
|
||||
// @Override
|
||||
// protected void initChannel(SocketChannel ch) throws Exception {
|
||||
// ChannelPipeline pipeline = ch.pipeline();
|
||||
// //pipeline.addLast(new LengthFieldBasedFrameDecoder (ByteOrder.LITTLE_ENDIAN,Integer.MAX_VALUE,0,8,0,8,true));
|
||||
// //pipeline.addLast(new LengthFieldPrepender(8));
|
||||
// //pipeline.addLast(new LengthFieldBasedFrameDecoder (Integer.MAX_VALUE,0,8,0,8));
|
||||
// //pipeline.addLast(new LengthFieldBasedFrameDecoder (Integer.MAX_VALUE,0,2,0,2));
|
||||
// //pipeline.addLast(new StringDecoder(CharsetUtil.UTF_8));
|
||||
// pipeline.addLast(new EchoSocketServerHandler());
|
||||
// }
|
||||
// })
|
||||
// .option(ChannelOption.SO_BACKLOG, 128)
|
||||
// .childOption(ChannelOption.SO_KEEPALIVE, false);
|
||||
// // @formatter:on
|
||||
//
|
||||
// ChannelFuture channelFuture = server.bind(28181).sync();
|
||||
// channel = channelFuture.channel().closeFuture().sync().channel();
|
||||
// } catch (Exception e) {
|
||||
// logger.error(e.getMessage());
|
||||
// } finally {
|
||||
// bossGroup.shutdownGracefully();
|
||||
// workerGroup.shutdownGracefully();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @PreDestroy
|
||||
// public void stop() {
|
||||
// if (channel != null) {
|
||||
// channel.close();
|
||||
// channel.parent().closeFuture();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user