Esempio n. 1
0
 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);
 }
Esempio n. 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));
   }
 }
Esempio n. 3
0
 public void messageReceived(IoSession session, Object message) throws Exception {
   CmdListener cmdListener = (CmdListener) session.getAttribute("CmdListener");
   cmdListener.setClose();
   session.close(true);
   cmdListener.onResponse((CmdResponse) message);
 }