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

import com.eactive.eai.adapter.EAIException;
import com.eactive.eai.adapter.socket2.config.SocketAdapterContext;
import com.eactive.eai.adapter.socket2.protocol.TcpAdapterClient;
import com.eactive.eai.adapter.socket2.protocol.fixedpayload.handshake.IgnoreFilter;
import com.eactive.eai.adapter.socket2.protocol.variableheader.codec.VariableHeaderCodecFactory;
import org.apache.mina.filter.codec.ProtocolCodecFilter;


public class VariableHeaderClient extends TcpAdapterClient {
	public VariableHeaderClient(SocketAdapterContext context) throws Exception {
		super(context);		
		this.handler = new VariableHeaderHandler(this);		
		config.getFilterChain().addFirst("codec", new ProtocolCodecFilter(new VariableHeaderCodecFactory(this)));
		
		/**
		 * ignore PING(ACK) message
		 */
		config.getFilterChain().addAfter("codec", "ignore", new IgnoreFilter(this));
	}
	
	@Override
	public Object sendMessage(Object message) throws EAIException {
		return super.sendMessage(message);
	}		
}
