本文整理匯總了Java中org.apache.mina.core.session.IdleStatus.WRITER_IDLE屬性的典型用法代碼示例。如果您正苦於以下問題:Java IdleStatus.WRITER_IDLE屬性的具體用法?Java IdleStatus.WRITER_IDLE怎麽用?Java IdleStatus.WRITER_IDLE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.apache.mina.core.session.IdleStatus
的用法示例。
在下文中一共展示了IdleStatus.WRITER_IDLE屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sessionIdle
@Override
public void sessionIdle(IoSession session, IdleStatus status) throws Exception {
com.lts.remoting.Channel channel = new MinaChannel(session);
final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel);
if (IdleStatus.BOTH_IDLE == status) {
LOGGER.info("{}: IDLE [{}]", sideType, remoteAddress);
RemotingHelper.closeChannel(channel);
}
if (remoting.getChannelEventListener() != null) {
RemotingEventType remotingEventType = null;
if (IdleStatus.BOTH_IDLE == status) {
remotingEventType = RemotingEventType.ALL_IDLE;
} else if (IdleStatus.READER_IDLE == status) {
remotingEventType = RemotingEventType.READER_IDLE;
} else if (IdleStatus.WRITER_IDLE == status) {
remotingEventType = RemotingEventType.WRITER_IDLE;
}
remoting.putRemotingEvent(new RemotingEvent(remotingEventType,
remoteAddress, channel));
}
}
示例2: sessionIdle
@Override
public void sessionIdle(IoSession session, IdleStatus status) throws Exception {
//System.out.println("SERVER: IDLE " + status + " " + session.getAttribute("idle"));
//System.out.println("Server: " + status + " " + session.getAttribute("idle") + " IIDDDEEEELLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL");
if (status == IdleStatus.WRITER_IDLE || status == IdleStatus.BOTH_IDLE) {
session.write(new HBMsg());
}
if (status == IdleStatus.READER_IDLE || status == IdleStatus.BOTH_IDLE) {
Integer idle = (Integer)session.getAttribute("idle");
if (idle == null) {
idle = 0;
}
++idle;
session.setAttribute("idle", idle);
if (idle == 5) {
//System.out.println("Server: CCCLLLOOOSSSINNNGGGG Session due to inactivity.");
session.close(true);
}
}
}
示例3: sessionIdle
@Override
public void sessionIdle(IoSession session, IdleStatus status) throws Exception {
//System.out.println("CLIENT: IDLE " + status + " " + session.getAttribute("idle"));
//System.out.println("Client: " + status + " " + session.getAttribute("idle") + " IIDDDEEEELLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL");
if (status == IdleStatus.WRITER_IDLE) {
session.write(new HBMsg());
}
if (status == IdleStatus.READER_IDLE) {
Integer idle = (Integer)session.getAttribute("idle");
if (idle == null) {
idle = 0;
}
++idle;
session.setAttribute("idle", idle);
if (idle == 5) {
//System.out.println("Client: CCCLLLOOOSSSINNNGGGG Session due to inactivity.");
session.close(true);
}
}
}