@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);
 }
Esempio n. 5
0
 @Override
 public String getLocalAddr() {
   return session.getLocalAddress().toString();
 }
Esempio n. 6
0
 @Override
 public int getLocalPort() {
   return session.getLocalAddress().getPort();
 }
Esempio n. 7
0
 @Override
 public String getLocalName() {
   return session.getLocalAddress().getHostName();
 }
Esempio n. 8
0
 @Override
 public int getRemotePort() {
   return session.getRemoteAddress().getPort();
 }
Esempio n. 9
0
 @Override
 public String getRemoteHost() {
   return session.getRemoteAddress().getHostName();
 }
Esempio n. 10
0
 @Override
 public String getRemoteAddr() {
   return session.getRemoteAddress().toString();
 }
Esempio n. 11
0
 /** decode finish, then enter into business process */
 void decodeFinish() {
   if (!decodeFinish) {
     session.fireReceiveMessage(this);
     decodeFinish = true;
   }
 }