package com.cisdi.data.HJ212.gateway;

import java.util.ArrayList;
import java.util.List;

import com.cisdi.data.sdk.gateway.netty.SessionFactory;
import com.cisdi.data.sdk.gateway.netty.impl.AbstractChannelInitializer;
import com.cisdi.data.sdk.gateway.netty.impl.AbstractIoChannelHandler;
import com.cisdi.data.sdk.gateway.netty.impl.DefaultIoChannelHandler;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.handler.timeout.IdleStateHandler;

public class Hj212ChannelInitializer<I> extends AbstractChannelInitializer<I> {
	private SessionFactory factory;
	
	/**
	 * 构造通道初始化器对象
	 * @param factory 会话工厂
	 */
	public Hj212ChannelInitializer(SessionFactory factory) {
		this.factory = factory;
	}

	@SuppressWarnings("unchecked")
	@Override
	protected AbstractIoChannelHandler<I> getTailHandler() {
		return new DefaultIoChannelHandler(factory);
	}

	@Override
	protected List<ChannelHandler> getHandlers() {
		List<ChannelHandler> handlers = new ArrayList<ChannelHandler>();
		handlers.add(new Hj212FrameDecoder());
		return handlers;
	}

	@Override
	protected IdleStateHandler getIdleStateHandler() {
		return new IdleStateHandler(15, 15, 30);
	}

	@Override
	protected ChannelHandler getSslChannelHandler(Channel socketChannel) {
		return null;
	}

}
