com.github.houbbbbb.sso.nt.initiallizer.ServerChannelInitializer Maven / Gradle / Ivy
The newest version!
package com.github.houbbbbb.sso.nt.initiallizer;
import com.github.houbbbbb.sso.nt.factory.ItemType;
import com.github.houbbbbb.sso.nt.factory.StaticFactory;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.LineBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import java.nio.charset.Charset;
/**
* @todo:
* @author: hbw
* @date: 2020/7/7
**/
public class ServerChannelInitializer extends ChannelInitializer {
@Override
protected void initChannel(SocketChannel channel) throws Exception {
try {
channel.pipeline().addLast(StaticFactory.getEncoder(ItemType.STRING_ENCODER));
channel.pipeline().addLast(StaticFactory.getDecoder(ItemType.LINE_BASED_DECODER));
channel.pipeline().addLast(StaticFactory.getDecoder(ItemType.STRING_DECODER));
channel.pipeline().addLast(StaticFactory.getServerHandler(ItemType.HEARTBEAT_SERVER_HANDLER));
}catch (Exception e){ e.printStackTrace(); }
}
}