package com.njcn.gather.detection.util.socket.service;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.util.CharsetUtil;

/**
 * @Description: 服务端初始化配置
 * @Author: wr
 * @Date: 2024/12/10 14:18
 */
public class NettyServerChannelInitializer extends ChannelInitializer<NioSocketChannel> {

    public static final NettyServerChannelInitializer INSTANCE = new NettyServerChannelInitializer();

    @Override
    protected void initChannel(NioSocketChannel ch) {
        System.out.println("初始化一次888888888888888888888888");
        ch.pipeline()
                //空闲状态的处理器
//                .addLast(new IdleStateHandler(10, 0, 0, TimeUnit.SECONDS))
                .addLast(new StringDecoder(CharsetUtil.UTF_8))
                .addLast(new StringEncoder(CharsetUtil.UTF_8))
                .addLast(new DevNettyServerHandler());
    }


}
