@Override
 public void flush() throws IOException {
   if (count > 0) {
     session.encode(ByteBuffer.wrap(buf, 0, count));
     resetBuffer();
   }
 }
  @Override
  public void write(byte b[], int off, int len) throws IOException {
    if (len >= buf.length) {
      flush();
      session.encode(ByteBuffer.wrap(b, off, len));
      return;
    }
    if (len > buf.length - count) flush();

    System.arraycopy(b, off, buf, count, len);
    count += len;
  }
 @Override
 public void close() throws IOException {
   try {
     flush();
     if (!keepAlive) session.close();
   } finally {
     if (!hasSavedAccessLog) {
       access.info(
           "{}|{}|{}|{}|{}|{}|{}|{}|{}|{}",
           session.getSessionId(),
           Monitor.CONN_COUNT.get(),
           request.getHeader("X-Forwarded-For"),
           request.getRemoteAddr(),
           response.getStatus(),
           request.getProtocol(),
           request.getMethod(),
           request.getRequestURI(),
           request.getQueryString(),
           request.getTimeDifference());
       hasSavedAccessLog = true;
     }
   }
 }
 public void write(File file, long off, long len) throws IOException {
   flush();
   FileRegion fileRegion = new FileRegion(new RandomAccessFile(file, "r"), off, len);
   session.encode(fileRegion);
 }
예제 #5
0
 @Override
 public String getLocalAddr() {
   return session.getLocalAddress().toString();
 }
예제 #6
0
 @Override
 public int getLocalPort() {
   return session.getLocalAddress().getPort();
 }
예제 #7
0
 @Override
 public String getLocalName() {
   return session.getLocalAddress().getHostName();
 }
예제 #8
0
 @Override
 public int getRemotePort() {
   return session.getRemoteAddress().getPort();
 }
예제 #9
0
 @Override
 public String getRemoteHost() {
   return session.getRemoteAddress().getHostName();
 }
예제 #10
0
 @Override
 public String getRemoteAddr() {
   return session.getRemoteAddress().toString();
 }
예제 #11
0
 /** decode finish, then enter into business process */
 void decodeFinish() {
   if (!decodeFinish) {
     session.fireReceiveMessage(this);
     decodeFinish = true;
   }
 }