employee -> system.out.println(employee) 中的
请问以下代码中
public class NettyServer {
// 端口号
private final int port;
public NettyServer(int port) {
this.port = port;
}
public void start() throws Exception {
ServerBootstrap serverBootstrap = new ServerBootstrap();//① 是一个启动NIO服务的辅助启动类
NioEventLoopGroup worker = new NioEventLoopGroup();
//②NioEventLoopGroup是用来处理IO操作的多线程事件循环器
serverBootstrap
.group(worker)
.channel(NioServerSocketChannel.class)
.childHandler(new ChannelInitializer<NioSocketChannel>() {
@Override
protected void initChannel(NioSocketChannel ch) {
ch.pipeline().addLast(new StringDecoder());
ch.pipeline().addLast(new SimpleChannelInboundHandler<String>() {
//读取客户端发送的消息
@Override
protected void channelRead0(ChannelHandlerContext ctx, String msg) {
System.out.println("【客户端发送的消息】"+msg);
}
} );
}
})
.bind(port);
}
请问 ,以上代码中
new ChannelInitializer<NioSocketChannel>() {
@Override
protected void initChannel(NioSocketChannel ch) {
ch.pipeline().addLast(new StringDecoder());
ch.pipeline().addLast(new SimpleChannelInboundHandler<String>() {
//读取客户端发送的消息
@Override
protected void channelRead0(ChannelHandlerContext ctx, String msg) {
System.out.println("【客户端发送的消息】"+msg);
}
} );
}
})
这是一个什么用法,new () {} 看不明白呀