use of org.atmosphere.runtime.AsyncIOWriter in project atmosphere by Atmosphere.
the class AndroidAtmosphereInterceptor method inspect.
@Override
public Action inspect(final AtmosphereResource r) {
if (!r.transport().equals(TRANSPORT.STREAMING))
return Action.CONTINUE;
final AtmosphereResponse response = AtmosphereResourceImpl.class.cast(r).getResponse(false);
String userAgent = AtmosphereResourceImpl.class.cast(r).getRequest(false).getHeader("User-Agent");
if (userAgent != null && (userAgent.indexOf("Android 2.") != -1 || userAgent.indexOf("Android 3.") != -1)) {
super.inspect(r);
AsyncIOWriter writer = response.getAsyncIOWriter();
if (AtmosphereInterceptorWriter.class.isAssignableFrom(writer.getClass())) {
AtmosphereInterceptorWriter.class.cast(writer).interceptor(new AsyncIOInterceptorAdapter() {
@Override
public void prePayload(AtmosphereResponse response, byte[] data, int offset, int length) {
response.write(padding, true);
}
@Override
public void postPayload(AtmosphereResponse response, byte[] data, int offset, int length) {
response.write(padding, true);
}
});
} else {
logger.warn("Unable to apply {}. Your AsyncIOWriter must implement {}", getClass().getName(), AtmosphereInterceptorWriter.class.getName());
}
}
return Action.CONTINUE;
}
use of org.atmosphere.runtime.AsyncIOWriter in project atmosphere by Atmosphere.
the class TrackMessageSizeInterceptor method inspect.
@Override
public Action inspect(final AtmosphereResource r) {
if (AtmosphereResource.TRANSPORT.UNDEFINED == r.transport() || Utils.webSocketMessage(r))
return Action.CONTINUE;
final AtmosphereResponse response = r.getResponse();
super.inspect(r);
AsyncIOWriter writer = response.getAsyncIOWriter();
if (AtmosphereInterceptorWriter.class.isAssignableFrom(writer.getClass())) {
AtmosphereInterceptorWriter.class.cast(writer).interceptor(interceptor);
} else {
logger.warn("Unable to apply {}. Your AsyncIOWriter must implement {}", getClass().getName(), AtmosphereInterceptorWriter.class.getName());
}
return Action.CONTINUE;
}
Aggregations