@Override
 public void sessionIdle(IoSession session, IdleStatus status) {
   if (session == null) {
     return;
   }
   if (status.equals(IdleStatus.READER_IDLE)) {
     log.error("World Model timed-out. Disconnecting.");
     this._disconnect();
     return;
   }
   if (status.equals(IdleStatus.WRITER_IDLE) || status.equals(IdleStatus.BOTH_IDLE)) {
     log.debug("Writing Keep-Alive message to World Model at {}", session.getRemoteAddress());
     session.write(KeepAliveMessage.MESSAGE);
   }
 }
示例#2
0
 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));
   }
 }