@Override
  public void sessionOpened(IoSession session) {
    // set idle time to 60 seconds
    session.getConfig().setIdleTime(IdleStatus.BOTH_IDLE, 60);

    // initial sum is zero
    session.setAttribute(SUM_KEY, new Integer(0));
  }
Esempio n. 2
0
 @Override
 public void sessionOpened(IoSession session) throws Exception {
   ok = true;
   this.session = session;
   // 会话打开时向服务端发送当前日期
   session.getConfig().setIdleTime(IdleStatus.BOTH_IDLE, 10);
   logger.warn("KingWeb(TCP),我連接上來了.....");
   this.session.write("{\"Action\":\"E\",\"Data\":[{}]}");
 }
Esempio n. 3
0
  /** {@inheritDoc} */
  @Override
  public void sessionOpened(IoSession session) throws Exception {
    SocketSessionConfig ssc = (SocketSessionConfig) session.getConfig();
    ssc.setTcpNoDelay(true);
    // ssc.setReceiveBufferSize(2048);
    // ssc.setSendBufferSize(2048);

    super.sessionOpened(session);
  }
 private void adjustReadBufferSize(IoSession session) {
   int maxReadThroughput = this.maxReadThroughput;
   if (maxReadThroughput == 0) {
     return;
   }
   IoSessionConfig config = session.getConfig();
   if (config.getReadBufferSize() > maxReadThroughput) {
     config.setReadBufferSize(maxReadThroughput);
   }
   if (config.getMaxReadBufferSize() > maxReadThroughput) {
     config.setMaxReadBufferSize(maxReadThroughput);
   }
 }
Esempio n. 5
0
 public void messageSent(IoSession session, Object message) throws Exception {
   CmdListener cmdListener = (CmdListener) session.getAttribute("CmdListener");
   session.getConfig().setIdleTime(IdleStatus.WRITER_IDLE, 0);
   session.getConfig().setIdleTime(IdleStatus.READER_IDLE, cmdListener.getReadTimeout());
 }
    @Override
    public void sessionCreated(IoSession session) throws Exception {
      super.sessionCreated(session);

      session.getConfig().setIdleTime(IdleStatus.READER_IDLE, 5);
    }