Beispiel #1
0
  /**
   * 设置状态
   *
   * @param state
   */
  public void setNextState(int state) {
    this.state = state;

    if (state == STATE_WRITE) {
      readBuf.position(0);
      readBuf.limit(0);
    } else if (state == STATE_READ) {
      writeBuf.position(0);
      writeBuf.limit(0);
    }
  }
Beispiel #2
0
 /**
  * 还需写多少字节
  *
  * @param remain
  */
 public void remainToWrite(int remain) {
   writeBuf.limit(writeBuf.position() + remain);
   setNextState(STATE_WRITE);
 }
Beispiel #3
0
 /**
  * 还需读多少字节
  *
  * @param remain
  */
 public void remainToRead(int remain) {
   readBuf.limit(readBuf.position() + remain);
   setNextState(STATE_READ);
 }