package com.eactive.eai.adapter.socket2.protocol.admin;

import com.eactive.eai.adapter.socket2.config.SocketAdapterContext;
import com.eactive.eai.adapter.socket2.protocol.TcpAdapterServer;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
import org.apache.mina.transport.socket.nio.SocketSessionConfig;

import java.nio.charset.Charset;


public class TelnetAdminServer extends TcpAdapterServer {
	public TelnetAdminServer(SocketAdapterContext context) throws Exception {
		super(context);
		this.handler = new TelnetAdminHandler(this);
		
		SocketSessionConfig sessionConfig = (SocketSessionConfig) config.getSessionConfig();
		sessionConfig.setTcpNoDelay(true);
		sessionConfig.setKeepAlive(true);

		config.getFilterChain().addFirst("codec", new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("UTF-8"))));
	}
}
