use of org.atmosphere.util.ByteArrayAsyncWriter in project atmosphere by Atmosphere.
the class WebSocket method transform.
protected byte[] transform(AtmosphereResponse response, byte[] b, int offset, int length) throws IOException {
AsyncIOWriter a = response.getAsyncIOWriter();
// NOTE #1961 for now, create a new buffer par transform call and release it after the transform call.
// Alternatively, we may cache the buffer in thread-local and use it while this thread invokes
// multiple writes and release it when this thread invokes the close method.
ByteArrayAsyncWriter buffer = new ByteArrayAsyncWriter();
try {
response.asyncIOWriter(buffer);
invokeInterceptor(response, b, offset, length);
return buffer.stream().toByteArray();
} finally {
buffer.close(null);
response.asyncIOWriter(a);
}
}
Aggregations