示例#1
0
 @Override
 public void sessionIdle(IoSession session, IdleStatus status) throws Exception {
   logger.error("-客户端与服务端连接空闲---发送心跳--sessionIdle:" + status.toString());
   // 发送心跳
   sendHeartbeat(session);
   if (session != null) {
     logger.error("-客户端与服务端连接空闲---session.close(true)---sessionIdle:" + status.toString());
     session.close(true);
   }
 }
 @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);
   }
 }
示例#3
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));
   }
 }