public class TrackMessageSizeFilter implements PerRequestBroadcastFilter {
@Override
public BroadcastAction filter(String broadcasterId, AtmosphereResource r, Object originalMessage, Object message) {
AtmosphereRequest request = r.getRequest();
if (r.uuid().equals(BroadcastFilter.VOID_ATMOSPHERE_RESOURCE_UUID) || "true".equalsIgnoreCase(request.getHeader(X_ATMOSPHERE_TRACKMESSAGESIZE))
&& message != null && String.class.isAssignableFrom(message.getClass())) {
String msg = message.toString().trim();
msg = msg.length() + "|" + msg;
return new BroadcastAction(BroadcastAction.ACTION.CONTINUE, msg);