package com.mortals.xhx.daemon.netty.server.controlserver;

import com.mortals.xhx.daemon.netty.server.controlserver.handler.NettyUDPServerHandler;
import com.mortals.xhx.module.device.service.DeviceService;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.DatagramChannel;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.timeout.IdleStateHandler;

import java.util.concurrent.TimeUnit;

/**
 * @描述 websocket netty init channel
 * @创建人 zxfei
 * @创建时间 2020/10/20
 * @修改人和其它信息
 */
public class ControlServerInitializer extends ChannelInitializer<DatagramChannel> {

    private DeviceService deviceService;

    public ControlServerInitializer(DeviceService deviceService) {
        this.deviceService = deviceService;
    }

    @Override
    protected void initChannel(DatagramChannel datagramChannel) throws Exception {
        ChannelPipeline pipeline = datagramChannel.pipeline();
        pipeline.addLast(NettyUDPServerHandler.class.getSimpleName(),new NettyUDPServerHandler(deviceService));

    }
}
