public void sessionIdle(IoSession session, IdleStatus status) throws Exception { CmdListener cmdListener = (CmdListener) session.getAttribute("CmdListener"); cmdListener.setClose(); session.close(true); if (status.equals(IdleStatus.WRITER_IDLE)) { cmdListener.onException(new Exception("发送超时")); } else if (status == IdleStatus.READER_IDLE) { cmdListener.onException(new Exception("接收超时")); } else { cmdListener.onException(new Exception("超时:" + status)); } }
public void exceptionCaught(IoSession session, Throwable cause) throws Exception { System.out.println(cause.getMessage()); CmdListener cmdListener = (CmdListener) session.getAttribute("CmdListener"); cmdListener.setClose(); session.close(true); cmdListener.onException(cause); }
public void sessionClosed(IoSession session) throws Exception { CmdListener cmdListener = (CmdListener) session.getAttribute("CmdListener"); if (!cmdListener.isClose()) { cmdListener.onException(new Exception("通讯未完成")); } }