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