當前位置: 首頁>>代碼示例>>Java>>正文


Java IdleStatus.WRITER_IDLE屬性代碼示例

本文整理匯總了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));
    }
}
 
開發者ID:WenZuHuai,項目名稱:light-task-scheduler,代碼行數:24,代碼來源:MinaHandler.java

示例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);
        }
    }
}
 
開發者ID:induwarabas,項目名稱:simple-event-loop,代碼行數:20,代碼來源:Server.java

示例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);
        }
    }
}
 
開發者ID:induwarabas,項目名稱:simple-event-loop,代碼行數:20,代碼來源:Client.java


注:本文中的org.apache.mina.core.session.IdleStatus.WRITER_IDLE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。