package com.cisdi.data.RFID.gateway;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

public class RfidClientInitializer extends ChannelInitializer<SocketChannel> {

    private RfidClient rfidClient;
    private RfidTaskStartVo startVo;

    public RfidClientInitializer(RfidTaskStartVo startVo, RfidClient rfidClient) {
        this.startVo = startVo;
        this.rfidClient = rfidClient;
    }

    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        //注册管道
        ChannelPipeline pipeline = socketChannel.pipeline();
        pipeline.addLast(new RfidFrameDecoder(startVo));
        pipeline.addLast("chat", new RfidClientHandler(startVo, rfidClient));
    }
}
