本文主要是介绍mina 2 心跳包,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
接收到心跳后先解码,先不调用经过messageReceived()方法,先触发心跳接收发送类KeepAliveMessageFactoryImpl中的isRequest()方法,当判断是心跳时,就会发一个心跳,不再调用messageReceived(),当判断不是心跳时,回调messageReceived()方法,输出内容。//服务器import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.charset.Charset;import org.apache.mina.core.service.IoAcceptor;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
import org.apache.mina.filter.keepalive.KeepAliveFilter;
import org.apache.mina.filter.keepalive.KeepAliveMessageFactory;
import org.
这篇关于mina 2 心跳包的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!